Use a comma to separate independent clauses in a compound sentence when they are separated by a conjunction.
The comma goes after the first clause and before the coordinating conjunction that separates the clauses.
Make sure they are independent clauses and not some other construction where commas are not required.
Correct: We washed the dog, and then we cleaned up the mess that he made.
(This contains two independent clauses with their own subject and verb: We washed and we cleaned. The third clause, that he made, is a subordinate clause, so the rule does not apply.
Incorrect: We washed the dog, and then cleaned up his mess.
(There is only one subject. This is a single clause, not two independent clauses. The subject we has a compound verb.)
Correct: We washed the dog and then cleaned up his mess.