My horse Tuffy was head shy when I first got him, but I taught him to relax and now he is not. I just consistently worked with him, let him know I'd never hit him, and eventually he came to trust me. I purposely waved my hands close, suddenly reach up and scratch his ear, grab his nose and rub it, whip a hand up with a treat, pull my hat off and put it on his head. He probably thought I was the strangest human he'd ever met, but harmless, and in a couple months he stopped whipping his head, flinching, or hardly batting an eye.
Unfortunately before he came around, my girlfriend Cindy waved a grain scoop at him while I was standing next to him and he whipped his head sideways and gave me a great big beautiful black eye. It felt like I had been punched by George Forman or maybe Mohammid Ali, whoever punches harder.
I just rub it all over with my hands slowly. Start with the area horse is somewhat OK about (say nose, or neck) and than gradually move upper and upper. It may not be done in one day, but eventually horse will realize you are not going to hit her.
Time. Patience, and Consistency. Both Tuffy and Kitten are right on with their posts. It takes a building of trust to overcome the fear that developed in your horse. There is no quick fix to this problem so just go slowly and speak to your horse as you work with him. It may never go away completely.
Dumas was headshy and still is to the extent that he won't let YOU touch him but my family has gained his trust and we can all handle his head now.
When we first got him a year ago we just kept rubbing his neck, We would rub higher and higher until he started getting uncomfortable. We would then make one quick swipe (softly of course) across his cheek, or across his poll or up his forhead....by the time he figured out what just happened it was already over and we were scratching low and happy spots again. Don't be skittish about it. Be VERY purpose-full. Have a clear cut plan on what you set out to accomplish that day. Make sure you take small steps and build trust. It took us about 3 months of literally being touch and go...(rub and stop) with him before we could halter him easily. Something else we did was replace the bridle he came with. It was one that had an ear keeper, we switched to a browband and he's much happier with bridling now too.
We just kept at it. Being calm and talking to him. Telling him everything we were doing, like we were talking to a mate. Soothing and relaxed.
We don't have issues with him being headshy anymore. I wanted to add that we also instruct people that come out to visit the horses to not rub his face. (most people go for the face right away) This keeps him in his comfort zone. Eventually, people like the farrier start rubbing his forehead. But, one time guests I don't even bother with.