Headaches at onset have various causes, some unavoidable (coffee withdrawal for many, carb withdrawal for most), some are (insufficient electrolytes or other nutrients).
Make sure you don't start with a vitamin deficiency, and add a little bit of salt to your drinking water.