The question : ‘Why do some*(see note below) birds bob their heads when walking?’ has perplexed scientists for many years. Some researchers suggest that head-bobbing may be correlated with the morphology of the retina, but others propose that it’s mechanically linked to the locomotor system, and that its visual functions are secondarily adapted.
Either way, one of the most comprehensive studies of head bobbing was authored in 2010 by Jennifer Hancock, a doctoral student at the Biknevicius Lab of Ohio University, US, in partial fulfillment of the requirements for the degree Doctor of Philosophy. Hancock not only investigated the head-bobbing phenomenon per-se, but also correlated it with the kinetics and kinematics of terrestrial locomotion in the Elegant Crested Tinamous (Eudromia elegans).

“These biodynamic studies found that birds have two distinct locomotor transitions. The first transition occurs as they move from vaulting mechanics to bouncing mechanics, and the second transition occurs when they incorporate an aerial phase during running. Thus, many birds use grounded running during intermediate speeds. Also, this study found in general that head and neck movements are coordinated with limb movements during terrestrial locomotion in charadriiform birds, but were not coordinated in the Elegant-crested Tinamou. Thus, the coordination is neither perfect nor obligatory.”

The Mechanics of Terrestrial Locomotion and the Function and Evolutionary History of Head-bobbing in Birds can be read in full via the link [194 page .pdf, relatively slow download]

* Note: Many species of birds don’t head bob, for reasons which are, as yet, not fully understood.

“Head-bobbing is not ubiquitous among birds. Although species known to headbob represent only 21 (12.8%) families out of the approximately 187 families in the Class Aves (Dunlap and Mowrer, 1930; Daanje, 1951; Friedman, 1975; Dagg, 1977; Frost, 1978; Pratt, 1982; Davies and Green, 1988; Wohlschlager et al., 1993; Troje and Frost, 2000; Fujita 2002, 2003; Cronin et al., 2005), sampling across Aves is quite sporadic. Furthermore, non-head-bobbing species have been reported in 16 (8.6%) families, six of which also contain head-bobbers. For the remaining 153 (81.8%) of avian families, no data on head movements during locomotion have been reported.”