The sostenuto pedal is most often used at the pianist's discretion. An obvious use would be to "catch" a pedal point note or octave in the bass in a measure where, if you attempted to do so and sustain it with the damper (loud) pedal, you would end up with a muddy blur. The sostenuto will hold that tone, while you make necessary pedal changes with the damper pedal in the same measure to retain clarity. For instance, although unmarked as such by the composer, the sostenuto can be used to good effect in Debussy's La Cathedrale engouitie starting in measure 28 to hold all the very low C pedal points. When it is specifically called for, it it generally marked by Sos. or Sost.
There is also a technique of which you would probably be unfamiliar. It's called "retaking the notes". A good example is Debussy's Les sons et les parfums in Book I of the Preludes. In the coda (the horn calls), there is a C# and E in the RH and an E and A in the LH, all tied of two and a half beats duration. Yet Debussy has us doing other things elsewhere on the keyboard with our hands after those particular notes are played, making it impossible to hold them to full value. The way we get around that problem in all four measures where it occurs is, while the damper pedal is still sustaining, we silently retake those particular notes in the third beat with our hands without actually playing the notes, thereby enabling those strings to sound more distinctly. So it's a variation of sostenuto without actually using the sostenuto pedal.
The soft pedal is often given as an explicit pedaling direction by the composer, but not always. Sometimes the direction is seen as una corda or due corde, as earlier pianos had a pedal that could shift the mechanism to either leave one or two strings sounding as degrees of softness. With the modern piano, two strings sound. Liszt, for example, indicates its use in some of his compositions, as do many other great composers. Apart from that, it is often used at the pianist's own discretion. But the caveat must be not to OVERUSE the soft pedal as a crutch. First, everyone should work hard at producing the p dynamic with the hands only. Generally speaking, there should be no need to use the soft pedal for p. Producing pp and ppp will also be a variable of the instrument, not solely the skill of the pianist. Note too that the soft pedal on a grand does not simply make the dynamic softer--it also significantly changes the timbre of the sound. You need to be keenly aware of that. Finally, understand that all dynamics are relative within the piece being played. For example, forte in a certain Beethoven sonata might be at a different level from forte in a particular character piece by Ravel. So dynamics are relative, not constant. This is an important consideration for this reason: suppose the entire piece were to contain only two dyanmics: pp and ppp. In that situation, if you were to squander the resources of the soft pedal on the pp sections, you would then have "no place to go" to get down to ppp elsewhere, which would spoil the performance.
Your last question has no answer that can be generalized, as it depends on the notation within the piece. If damper pedal is used extensively throughout the composition, it would make little sense to play the last few notes of the coda "dry", as it would be inconsistent within the overall context. When you say it sounds different both ways, remember that when the damper pedal is depressed, it is lifting the dampers from all the notes that have dampers, not just the dampers for those last few notes in the last bar. That means that when the damper pedal is down, you're getting overtones and sympathetic vibrations from other strings too--a far different scenario from simply depressing a triad with no pedal and having those three strings sounding in isolation. If the coda is clearly nonlegato, then playing without pedal would make much more sense. Staccato would also be more effective without any damper pedal, since the damper pedal would gloss over the crispness of the staccato effect, effectively obliterating it.
The very important question which you did not ask in your query is when NOT to use the damper pedal. Whenever you are dealing with figuration in passwork consisting of many passing and neighboring tones, those measures are best played with no pedal, or with very sparing pedal where fleeting moments permit. Otherwise, it'll all be an unmusical blur. For example, in Rachmaninoff's well known Prelude in g, Op. 23, No. 5, the entire coda, marked leggiero, is played without pedal. Not only is it replete with passing tones, but pedal would distort the lightness of touch required there. But Rachmaninoff does not show a pedal direction there, nor does he in the vast majority of his pieces. He expects the pianist to know how to handle the pedals through analysis. Similarly, in the ultra-romantic Prelude Op. 23, No. 6, that coda is double note passing tones--also no damper pedal used there. A final example of little or no damper pedal is Chopin's dreamy and melancholy Etude Op. 10, No. 6 in e flat. Students are sometimes shocked to learn that such a lyrical piece with bel canto melody is to be played with no damper pedal! Yet it's the only way to truly preserve the clarity of the fillagree intertwined with the melodic line.
The best advice I can give on the damper pedal in particular is that it is totally and meticulously governed by the artist's alert and discerning ear. And as indicated above, important judgments have to be made very carefully. The damper pedal gets by far the most use, is the soul of the piano as Liszt used to say, so is most crucial. The soft pedal receives a fair amount of use, but must not be a crutch. The sostenuto is more exotic, coming into play a very small fraction of the time. In fact, for decades, many fine European pianos did not have sostenuto pedals at all.