Our Shaykh, Muḥammad ibn Ḥizām, may Allāh preserve him, was asked the following question:
Question: “When is the prostration of forgetfulness performed: before the Salām or after the Salām?”
Answer: “If the Imām made a mistake in terms of an addition, then the prostration is made after the Salām. If there is a decrease in some of the obligations, then the prostration is done before the Salām. This is because the Prophet (ﷺ), when he increased the prayer with a Rak’ah, made the prostration after the Salām and when he decreased by forgetting the first Tashahhud, he made the prostration before the Salām.
The one who comes late to the prayer while the Imam already prayed one rak’ah or two, then if the Imam makes the prostration before the Salām, he follows him. If the Imām makes prostration after the Salām, then then the latecomer does not follow him in that time because the Imām divided between the Two Salāms. So then a latecomer stands and completes his prayer, then he prostrates after the Salām. When he completes the prayer himself, then he makes the prostration after the Salām himself following [the action] of the Imām”. End. [Reference]
Translated by
Faisal bin Abdul Qaadir bin Hassan
Abu Sulaymaan