I think it's a problem with the diet, most of the time. As an hvac technician-I know that carbon monoxide causes headaches in mild cases of exposure-death in extreme ones.
So, if you have a gas furnace in the place that you live-then you might be breathing carbon monoxide-and if so, then your heat exchanger is cracked, and must be replaced.
If you drink too much-then you're going to be depleted on water soluble vitamins such as any B vitamin, C, etc. . . . .so take a supplement, or eat foods rich in those. If you take a supplement of either-then you need to take it with food.
Hope I was helpful. :-p