When your metal fillings meet tin foil, the body’s weak electrical impulses create a closed circuit and you have essentially form a weak battery. Remove the foil and it stops. You aren’t electrocuted but you will feel a slight buzzing. Your fillings must be pretty close to the nerve in your tooth so that would explain the hurt.
The same way a battery works- different metals hold their electrons with different strengths- so when your amalgam fillings touch the aluminium foil a current flows, which your nerves react to (contrary to the below it’s not the body producing the current).
Edit: More people need to remember the high school science lesson with the nail and the copper stick and the saltwater and the ammeter. And someone should really see about fixing that shower..
Edit II: The Revenge Of The Edit: I guess it /could/ be the body’s own electrode potential interacting with the foil if no fillings are involved. Also apologies for omitting the electrolyte in form of saliva. Was thinking of galvanic corrosion, which doesn’t require one. Is why aluminium and steel will corrode together over time in direct contact.
Latest Answers