The origin of Sri Panchamukhi Hanuman can be traced to a story in Ramayana. During the war between Lord Rama and Ravana, Ravana took help of Ahiravana, the king of Pathala. Lord Hanuman in order to protect Lord Rama and Lakshman formed a fortress with his tail. Ahiravana took the form of Vibhishana the noble brother of Ravana and took Lord Rama and Lakshman to Pathala loka.
Hanuman entered pathala loka in search of Rama and Lakshmana, He found that life of Ahiravana was hidden in the five lamps which were placed in different directions. He could be killed only by extinguishing all five lamps the same time. To accomplish this Hanuman had to take the form of Panchamukha Hanuman. This form of Hanuman has five faces. Hayagriva, Narasimha, Garuda and Varaha are the four other faces along with Hanuman’s face. Hanuman using the five faces in different directions blows air to extinguish the lamps there by killing Ahiravana.

Every Face of Shri Panchamukha Hanuman has a significance

Hanuman – Signifes Courage, Devotion, Selfless-Service

Narasimha – Narasiṃha indicates God’s omnipresence and the lesson is that God is everywhere. Narasiṃha demonstrates God’s willingness and ability to come to the aid of His devotees, no matter how difficult or impossible the circumstances may appear to be.

Garuda – The mount of Lord Vishnu – Garuda is invoked as a symbol of impetuous violent force, of speed, and of martial prowess.

Varaha – Vishnu as Varaha, rescues mother earth from the demons.

Hayagriva – During the creation, the demons Madhu-Kaitabha stole the Vedas from Brahma, and Vishnu then took the Hayagriva form to recover them.

Sri Vigneswara(Ganesha) and Sri Anjaneya(Lord Hanuman) are the only two deities who are totally free from any influence over them whatsoever by the Navagrahas(Nine Planets).