This may be a silly question, but you are fasting for two days and eating normally for 5 aren't you?
This common problem has many causes. Headaches during a fast could be due to dehydration or hunger, poor rest, or the absence of addictive substances such as caffeine or nicotine.
A moderate and balanced diet, especially not missing the pre-dawn meal, taking in enough fluids and, if necessary, some painkillers such as paracetamol, can help prevent or reduce the risk of headache.
Headaches can also be prevented by not exposing yourself to direct sunlight, wearing a hat when out, using sunglasses to reduce the effect of glare from the sun and relieving any tense muscles with a short, gentle massage.