Riboflavin is essential for keeping your cells stable and to produce energy. It is used as a headache preventive at the 400mg dose per day. In the literature, there are a few trials to support it. In fact, there are only two.
In one trial by Schoenen and colleagues, 55 people were divided into two groups. The group that took Vitamin B-2 400mg for 3 months experienced greater than 50% reduction in their headaches. Another study by Maizels and colleagues using 49 people had similar results.
What scientists would like to see are more trials, of course, with larger study groups. However, funding for such trials is very difficult to come by.
Riboflavin should be taken in the morning. Since it gives you energy, that energy would be of best use to you in the daytime. If you take it in the afternoon, you might have problems sleeping. It does also turn your urine fluorescent yellow. It is very well tolerated but rarely, someone may experience stomach upset or diarrhea.
Although it is a vitamin, using it for a headache preventive in pregnancy cannot currently be recommended since the dose effect on the fetus is unproven.