The maliki view according ar-Rissala p282-290 of ibn abi Zayd al-Qayrawani is (with some comments):
Any time you inadvertently add something to the prayer you should do two sajdas after saying the salam and then do the tashahhud and say the salam again.
If one adds a raka'a or starts an additional raka'a one should perform the prostration after the salam. (Here the malikis don't make any difference in the ruling between fard or nafl prayer).
If you miss something out of the prayer you should do two sajdas before saying the salam after having finished the tashahhud. You then do the tashahhud again and say the salam.
So only if you missed something out of the prayer a prostration of forgetfulness is done prior to salam. Eight sunnahs (muakkadah) have been counted for which one should perform this sujud if one misses one of them (with a difference between fard and nafl prayers) or misses minor two minor sunnah acts of the prayer:
- forgetting the recitation of more than al-Fatiha in fard prayers (only).
- forget reciting out loud in the prayers which are out loud (fard only).
- forget reciting out silent in its place
- forget any takbir except takbir al-Ihram (at the beginning of the prayer)
- forget the words "Allah hears whoever praises Him." (smi'a Allahu liman hamidah)
- forget the first tashahhud or its sitting for the first tashahhud or its words.
- forget the final tashahhud
(For details of other schools of fiqh refer to Jurisprudence of the four sunni schools page 599ff)
So the view of ibn al-Qasim is to do this after the -last- tashahhud and perform the tashahhud again afterwards.
Some people say that it is not necessary to repeat the tashahhud.
This was related by Malik and others.
If you both leave something out and add something you do the two sajdas before the salam.
this is basically the view of imam Malik:
If you added something to the prayer you'll have to do the sujud as-sahw after salam (in this case only an intention is necessary, as one left the prayer by performing salam).
If you missed or missed and added something you may have to do it before the salam (in this case an intention is not needed as this is considered part of the prayer).
Which actually differs to some extent from what al-Jaziri says in his Jursiprudence of the four sunni schools (page 597).
If you forget to do the two sajdas which should be done after the salam you do them whenever you remember them even if a long time has elapsed.
So you may do "qada'" of the prostration of forgetfulness according the maliki school of fiqh and should be performed in the correct manner for example the sujud (sahw) before salam should be done before salam. However if you've missed them several times you should redo the prayer.
Imam a-Shafi'i holds the opinion that one always needs to perform sujud as-sahw before the salam (as explained above), but with an inward intention (for the imam and those who pray alone only). If speaking aloud between the salam and the prostration of forgetfulness the prayer would be invalid. (For details refer to to Jurisprudence of the four sunni schools page 596)
Imam abu Hanifa holds the opinion that one should always perform the sujud as-sahw after the salam on the right -only- (with an intention to perform it). The Hanafis say one should perform the tashahhud afterwards (again) but if one misses it the prayer would be valid, with a neglected duty. (For details refer to Jurisprudence of the four sunni schools page 596).
The hanbalis say performing sujud as-sahw before the salam is preferred except for two reasons: if one has left out a whole rak'a one should perform it and do the prostration of forgetfulness after the salam. And the secoind is if the imam has an uncertainty concerning some part of his prayer. Note that if the sujud as-shaw was after the tashahhud one doesn't need to perform it again which si also the view of the shafi'is. (For details refer to Jurisprudence of the four sunni schools page 598)