Headaches have various causes, and you have to look at where the pain is "originating" from to even try and figure out why. Going out of a walk could be due to a sinus getting irritated and going out for fresh air helps relax it. It can also just be a stress headache and going for a walk relaxes you.
Oh I fully agree that it working depends on the cause of the headache. But when one doesn't know the cause, it's well worth a try.