The role of the comma is to divide the sentence and indicate the pauses occurring in speech.
In lists, the comma is placed between words of the same type or between similar groups of words if they are not linked by und or oder.
The comma separates some qualifying phrases from the rest of the sentence.
An infinitive phrase is usually divided from the rest of the sentence by a comma; zu + infinitive alone is not necessarily divided off.
The comma separates main clauses but may also be omitted if the clauses are linked by und or oder. However the comma is never used between main clauses linked by und or oder if one part of the sentence is common to both clauses.
The comma separates the subordinate clause from the main clause.