Babies are born with a variety of innate reflexes. The rooting reflex prompts a baby to turn his head from side to side, especially if you touch his cheek or mouth. Babies are also born with the ability to suck automatically. Rooting and sucking are survival reflexes that help a baby learn how to eat, and these actions become less reflexive and more directed over the first few weeks and months of life.
References
Shelov, S. P. (Editor-in-Chief). (2004.) Caring for Your Baby and Young Child: Birth to Age 5. The American Association of Pediatrics. Revised edition. New York: Bantam Books.