I do neck stretches and lie down on the floor for a few minutes with a rolled up towel under just my neck. In my case my head hurts because my neck is pinched. An ice pack to the temples helps too.
However I think this is one of those cases of an ounce of prevention is worth a pound of cure. If you start tracking things like foods, sleep, and stress levels you might be able to find and eliminate the cause.