I think cuarto is the most general term for any room for whatever use, dormitorio is strictly for sleeping, habitación somehow between but generally as any room that is used to live, even temporarily like hotel rooms. Any room for working you wouldn't call habitación normally. Sala is mainly used as living room or a big room like a hall, sometimes for dining.
They have the same meaning.
-Dormitorio and Habitación are more used often in Spain -Cuarto is more used often in Central Mexico.
But don't worry too much about this, both countries understand perfectly the meaning of Habitación, Cuarto and Dormitorio without problems, because they use these words as synonymous.
-In countries like Argentina, they use more often "Pieza". -Also there's are some other words like "recámara" and "alcoba", but at least in Spain and Mexico, it can be a little bookish. -Cuarto, futhermore, means a "quarter" or "fourth". So by context it can change the meaning.
I hope that this helped you.