Why does aluminum foil "electrocute" dental fillings?
Ouch...  actually a known phenomenon.  Between the foil of aluminum/Al, and the metal filling of amalgam in your tooth, you created a little electrochemical cell.  Your saliva served as an electrolyte and your nerves around sensibly detected the current. This already "works" with little splinters of Al foil wrapping chocolate (obviously, it was not a small Hershey bar), yet is less powerful than the said 9 V block.

(one reference)