Which is not to say coffee as a treatment, but treatment for coffee. Being over-coffeed, that is.
These days I generally limit myself to one diner mug's worth of coffee in the morning. When I skip coffee, I don't have headaches, presumably because I don't drink much. My body doesn't crave the caffeine--coffee's a luxury, not a necessity in this respect.
I once was addicted to caffeine, however, and would get these insistent headaches if I ever skipped a day. Like an attention-starved child, coffee would demand my attention via headaches.
There were some things that I used to do to mitigate those effects. First, I would load up on potassium. Coconut water is a great source, as is most fruit. Bananas, dates, strawberries...pick your favorite.
I would also take magnesium supplements. I still do that, not with a view to mitigating headaches, but for other health reasons.
The best way to treat being over-coffeed, of course, is to limit one's intake. It's a delicious beverage, and healthy in moderation by most accounts, but too much means *too* much.
* I spent 10 minutes trying to upload a picture of a freshly opened coconut and a mug of coffee, to no avail. Oh well.