There are excellent tips here and maybe what they suggested will help you. You might want to pack a little Anacin with you--it has caffeine and it may help your headache.

I found my long rides are much more enjoyable if I stop for just a few minutes to stretch. It also keeps aches and pains at bay.

My hubby discovered that he gets headaches because he's essentially underhydrated.