The origin of Sri Panchamukhs Hanuman can be traced to a story in Ramayana. During the war between Lord Rama and Ravana. Ravana took help of Mahiravanka who is the king of Pathala.
Lord Hanuman in order to protect Lord Ram and Lakshman formed a fortress with his tail. Mahiravana took the form of Vibeeshana and took Lord Ram and Lakshman to pathala loka. Hanuman entered pathala loka in search of Rama and Lakshmana, He found out that to kill Mahiravana he had to extinguish five lamps burning in five different directions at the same time, so he has taken the Panchamukhi form with Hanuman, Hayagriva, Narasimha, Garuda and Varaha faces and extinguished the lamps and killed Mahiravana.
According to Hanumath Prakaranam in Sri Vidyarnavatantram, Anjaneya has five faces (Pancha Mukha) and ten weapons. The five faces are that of Lord Hanuman, Lord Narasimha, Lord Adivaraha, Lord Hayagriva, and Lord Garuda.
Hanuman is a great yogi (mystic) having transcended the five senses (Pancha Indriyas).
In Kamba Ramayanam (in Tamil), the significance of number five is beautifully narrated as follows:
Sundara Kandam, which highlights the heroic exploits of Lord Hanuman at Lanka is the fifth canto in the Ramayana. Therefore, it is considered auspicious to go around His idol 5 times, 14 times, 23 times, 32 times or with such numbers the digits of which add to five.
The Panchamukhi hanuman is rare idol of Hanuman. There are many legends and interpretations to same.
Lord Hanuman is said to have appeared before Raghavendraswamy in a unique way amalgamating within him the avataras of “varaha, garuda, anjaneya, narasimha and hayagreeva”, thus five-headed. Panchamukhi, located on the south bank of river Tungabhadra near Manchala now known as Mantralayam is where Raghavendraswamy performed penance for 12 long years in a cave. In appreciation of his Yoga, Lord Panchamukhi Pranadevaru, Kollahpura Mahalakshmi, Lord Venkateshwara of Tirupati and Kurmavathara gave darshan to him. Then he left for Mantralaya where he entered into Samadhi. A temple has been constructed at the spot where he performed penance known as the Panchamukhi Anjaneyaswamy temple.
The description for 5 Faces of the Hanuman Idol ( Panchamukhi) is as follows: