I believe it is dependant on the cause. For instance it is excellent for migraines, where the blood vessels in the brain dilate, causing pain. Caffeine causes them to constrict.
On the other hand it is terrible for normal headaches, wherein the blood vessels are already constricted.