Why does foil make your teeth hurt if, say, you eat chocolate and there’s some foil left on?
This is a well-known phenomenon when metallic objects come into contact with fillings. If the object is made out of a different type of metal than the filling, there will be galvanic action between the two.
Galvanic action occurs because different types of metal have a different likelihood of becoming ions. For atoms in the metal to become ions, there must be electrons available, usually from a solution such as water. So, if you have two metals, with different likelihoods of becoming ions, and water (or saliva) in between, electrons will move from one to the other. The movement of electrons is the same as saying that an electric current is flowing. So you get a tiny electric shock that sets off the nerve endings in your teeth, which hurts.