A complex sentence is made up of an independent/main clause and one or more dependent/subordinate clauses.
A clause is a group of words that contains both a subject and a predicate.
When I get up in the morning, I am hungry.
An independent clause is a complete thought. It can stand alone as a sentence.
I am hungry.
A dependent clause is not a complete thought. It cannot stand alone as a sentence.
When I get up in the morning
The dependent clause in a complex sentence usually begins with a subordinating conjunction such as if, when, after, although, as, because, before, since, unless, until, or while.
A comma is generally used to separate a dependent clause from the independent clause if the dependent clause comes first.
Because her alarm clock was broken, she was late for class.
A comma is not used to separate a dependent clause from the independent clause if the independent clause comes first.
She was late for class because her alarm clock was broken.