I very rarely get headaches, but two things that have triggered headaches for me are red wine - especially when I've had it for several nights in a row, and decaf coffee (regular might do the same thing, I haven't had it in ages).
How might these two phenomena be related? Could it be the tannins, and if so, why?
Both are known migraine triggers for some migraine sufferers. Try dropping both out of your diet for a week or so, then reintroducing one for 3 days and see what happens. Then try the same with the other, with another week in between if the first triggers headaches.
Wine is high in histamines, and if you have an intolerance to them it can be a trigger for a migraine, as mentioned. I'm not sure about the coffee though as I thought it was caffeine which could lead to a migraine but if your drinking decaf then I'm not sure.
Some folks have coffee allergy due to roach parts. Yep. Another good reason to stick to whole, real foods. Or grind coffee yerself. http://www.chow.com/food-news/7541/fresh-hot-cup-of-cockroaches/