Caffeine is a ‘double-edged‘ sword. Too much (or in some very sensitive individuals, any) will cause headaches, while some will help headaches. Caffeine is used as an ‘adjunct’ to certain analgesics (65mg of caffeine in Excedrin, 32mg in Anacin), enhancing the effect of the nsaids. Studies have shown that adding small amounts of caffeine to ibuprofen renders it more effective than ibuprofen alone.
I try and keep people below 150mg daily of caffeine. Of course, sensitivity to caffeine varies widely; some experience rebound headaches from a little, while others may consume large amounts and not suffer rebound.
The caffeine content of the various substances is listed elsewhere on this site; a typical cup of brewed coffee has 150mg, while instant has 50 to 75mg. Starbucks is much stronger. tea (if it has caffeine) has about 30mg per cup, while a can of coke has 40mg. It is very important to regulate, or consider eliminating, your caffeine consumption.