There are two ingredients in chocolate that can trigger migraine headaches: caffeine and phenylethylamine. These substances can constrict blood vessels, and constriction causes head pain.
Some people get a headache if they eat chocolate but not when they drink caffeinated beverages. That is because some people may be sensitive only to phenylethylamine, while others are sensitive only to caffeine. Some people may be sensitive to both.