This claim is true to an extent, as caffeine can be both an aid and a cause of headaches. Caffeine has direct effects on your nervous system, and can trigger headaches, but can also soothe them depending on how often and how much you are consuming at a time. If you frequently drink caffeine, caffeine withdrawals can cause very aggressive headaches and borderline migraines.
According to the National Library of Medicine article “Caffiene for headaches: Helpful or Harmful?” they state that caffeine consumed once a day in the correct amount of doses could be beneficial to different aspects of your life such as attention span, energy, and physical fitness. On the other hand doses of caffeine that are too high or too often can have the opposite effect, by implementing anxiety, tremors, insomnia and more. This all supports the idea that caffiene can have beneficial qualities, but can ultimately be a leading cause for headaches for some.
Healthline debates the fact that constant caffeine can also cause one to have caffeine withdrawal, ultimately making caffeine a leading cause in their headaches. According to Healthline, caffeine can enhance already working over the counter drugs such as Tylenol and Asprin when you have a headache, but if said headache is from a caffeine withdrawal there could be a repetitive cycle that never ends. In the end they conclude with the fact that, “it seems that caffeine can reduce pain from headaches, or at least increase the strength of your pain medication. It has been medically proven by multiple different people and sites to be both a contributor to headaches and an aid to headaches.
https://www.healthline.com/health/caffeine-headache#as-a-cure
https://pmc.ncbi.nlm.nih.gov/articles/PMC10385675/