A mole can get infected from outside bacteria or debris that finds its way inside. One way this may happen is from shaving; if a razor cuts open the top and exposes the inside, outside bacteria can cause an infection. If this happens, a healthcare provider may need to see the mole and remove it.