Something as simple as practicing Tadasana (Mountain Pose) can help eliminate bad postural habits and serve as a reminder to lift the head up and away from the shoulders rather than crunching it into the neck. If the head is thrust forward, gently sliding the chin toward the throat until the ears and shoulders line up will bring it into a more neutral position.
Stretching and strengthening the muscles in the upper torso can also help relieve tension in the neck and head. Adho Mukha Svanasana (Downward-Facing Dog Pose), the mainstay of hatha yoga practices, accomplishes this balance most efficiently. But although some instructors and texts (including B.K.S. Iyengar's Light on Yoga) suggest inverted asanas as part of a headache-relieving sequence, many headache sufferers find even as simple an inversion as Downward Dog uncomfortable, due to the increased sense of pressure in the head. A modified version of Downward-Facing Dog, standing with the palms on the wall and torso parallel to the floor, provides many of the same benefits without allowing the head to fall below the heart.
When a headache is at its worst, even dedicated yogis can find an intensely active practice excruciating. Relaxing, restorative postures are preferable during those times. Most important, if something creates strain, don't do it.