People with headache have anxiety and/or depression at higher rates than those without headaches; we look at these conditions as “shared comorbidities” that people inherit. When people are born, they are more prone, genetically, to these conditions. I believe they are “side by side” conditions that we inherit, not that depression causes headaches or vice versa. Certainly, severe headaches may fuel and increase anxiety and depression, and depression may worsen headaches, but these medical comorbidities do not actually CAUSE each other.
Headaches are a physical, not psychological, illness, and the same for anxiety/depression; there are many differences in the brain for all of these situations, and viewing them as “all in your head, or psychological” is unfair and misleading.
These comorbidities do drive where we go with medications, so if someone has headaches and depression, we would usually try and find an antidepressant that treats both. Just like if a person has headaches and high blood pressure, we would go with high blood pressure meds. The idea, of course, is to minimize meds, and attempt to treat 2(or 3) conditions with one medication. Exercise,yoga/pilates,psychotherapy, etc. are also crucial for those with anxiety/depression.