(a) It is narrated from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) prayed Zuhr as five rak'ahs. When he gave the salam ending the prayer, someone said: "Has something been added to the prayer?" He (peace and blessings be upon him) said: "No." The Companions said: "But you prayed five rak'ahs," so he (peace and blessings be upon him) performed two prostrations.
(b) Another narration does not mention Zuhr; in it, it says that when he turned away from the prayer, he performed the two prostrations of forgetfulness.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3880
Salamah bin Nubayt (may Allah be pleased with him) narrates: I prayed at home and made a mistake through forgetfulness during the prayer. Then I came to al-Dahhak bin Muzahim (may Allah be pleased with him) and said to him: I prayed in my house and I forgot. He said: Perform the prostration of forgetfulness now.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3881
Imam Hasan al-Basri (may Allah have mercy on him) states: When a man forgets in the mosque and does not perform the prostration of forgetfulness until he has left the mosque, there is nothing upon him.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3882