As well as checking with your doctor, you could try getting a new pillow and/or turning your mattress. Last year I had to take painkillers many nights because of headaches that seemed to come out of nowhere.
Only when I got a painful neck did I realise that the cause was my pillows. Somehow they were putting my head and neck at an awkward angle and causing the headaches.
I don't know if that's what's causing your problem, but it's something else to look at maybe.