A complex sentence is made by combining an independent clause with a subordinate clause. You do not need a comma in a complex sentence where the independent clause comes first. But anytime you begin a complex sentence with a subordinate clause, you must put a comma after the subordinate clause.
A subordinate clause always begins with a subordinating conjunction. Look at this list of subordinating conjunctions: after, although, before, if, since, when, where, while, because, during, unless, until
When you begin a sentence with one of these words at the start of a clause, you are writing a complex sentence. That subordinate clause needs a comma after it, before you write the independent clause.
Here are some subordinate clauses:
Before it gets dark
After we finish the game
When the bus gets here
Each of these clauses needs a comma before adding the independent clause.
Before it gets dark, I will mow the lawn.
After we finish the game, we can get ice cream.
When the bus gets here, we will climb on.
Always put a comma after a subordinate clause in a complex sentence.
▶Now you try it. Does this sentence need a comma? If so, where would you put it? If the dog is sleeping don’t wake him up. Do you see the subordinate clause at the beginning of the sentence? Did you put a comma after it? Good for you!