Ta'wiz for Headache and Earache
It is narrated from Imam Muhammad al-Baqir (as) that to stop a headache one should pass the hand over the head and recite this dua seven times:
أَعُوذُ بِاللَّهِ الَّذِي سَكَنَ لَهُ مَا فِي الْبَرِّ وَالْبَحْرِ وَمَا فِي السَّمَاوَاتِ وَالْأَرْضِ وَهُوَ السَّمِيعُ الْعَلِيمُ
Translation: I seek refuge in God, by whose command everything is held still that is on land and sea, in the heavens and the earth, and He is the All-Hearing, the All-Knowing.
It is narrated from Imam Ja'far al-Sadiq (as) that for earache too this same dua should be recited seven times. It is also reported from him (as) that one should take very old cheese, grind it fine and mix it in milk, then warm and soften it over a fire; then put a few drops of it into the ear of the one who has the earache.
After that, send salawat upon Muhammad and the family of Muhammad (s), and invoke curses upon the enemies of Muhammad and the family of Muhammad (s).