Answered by Ustadh Tabraze Azam
Question:  When you are praying behind an imam and he makes a mistake such as praying five raqas for dhuhr, and one says something like subhan Allah but the imam keeps on with the mistake, should one follow him or pray correctly.  My other question is should one make sajdit assahu if the imam makes this sajda? Or only if you make a mistake?
Answer: Wa alaikum assalam wa rahmatullahi wa barakatuh,
I hope you are in the best of health and spirits, insha’Allah.
 If the imam stands up for the fifth cycle (rak`at) of the noon (dhuhr) prayer, the followers should remain seated and correct him by saying the tasbih (subhanAllah).
If the imam prostrates for the fifth cycle (rak`at), there are two cases:
[a] If he sat for the extent of the tashahud in the final sitting (qa`dah), you would say the salams and finish your prayer,
[b] If he did not sit for the extent of the tashahud in the final sitting (qa`dah) or did not do the final sitting altogether, the prayer of the imam and the followers would be invalidated. Thus, they would all need to repeat their prayer.
 If the imam performs the prostration of forgetfulness (sahw), the follower does so too as he is following the imam. However, if the follower makes a mistake requiring the prostration of forgetfulness (sahw), he does not prostrate.
[Haskafi, al-Durr al-Mukhtar; Ibn `Abidin, Radd al-Muhtar; Shurunbulali, Imdad al-Fattah]
And Allah alone gives success.
Checked & Approved by Tabraze Azam