A complex sentence is a type of sentence made up of an independent clause (a clause that expresses a complete thought) and a dependent or subordinate clause (a clause that can not stand alone as a sentence because it does not express a complete thought). In this type of sentence, the dependent clause is often introduced by a coordinating conjunction such as <em><u>when</u></em>(like in the sentence given), <em>after, while, because, since, if </em>and<em> until</em>, which also indicate the subordination of the clause to the independent clause.
The sentence given is structured like a complex sentence: It has a dependent clause, which it's <u><em>When Sara turned her homework in</em></u> and a dependent clause: <u><em>she forgot to put her name on it.</em></u>