Expert answer:
There are two possibilities: herpes causes a headache (so the pain manifests just before the herpes outbreak is a sign of viral activity), or the herpes outbreak is caused by the same factor that causes the headache ( in this case the suspicion is about emotional problems, which can cause the headache and the eruption of herpes lesions).