It's the SPIT rule Helene.
S- words, phrases, clauses in a SERIES are separated by a comma e.g. There are chairs, tables and rugs in the room.
P - PRINCIPLE clauses linked with a conjunction (and, but, or) --Clark arrived on time, but Lois was late.
I - An INTRODUCTORY word, phrase or clause is followed by a comma. e.g. Nevertheless, Lois was annoyed.
or
Wishing that she had spoken to Clark first, Lois plunged into the deep water.
T - THOUGHT INTERRUPTION (The comma comes before and after. The first one signals a "detour"; the second brings the reader back to the main road.) e.g. Clark, a part-time superhero, manages to save the day on a regular basis.
Those are the basic rules. And of course, there are exceptions (and there are the rules of dialogue punctuation).
Hope that helps.
gerry