Placing a subordinate clause before a main clause in a sentence

A subordinate clause that begins with a subordinating conjunction can usually be placed either before or after the main clause it modifies. That doesn't affect the word order of the subordinate clause. But if the subordinate clause comes first, then the verb in the main clause moves to the beginning of that clause, right after the comma. Another way of looking at it is that the subordinate clause is in the first position of the compound sentence. So the verb can still be considered to be in the second position.

Main clause     Subordinate clause
Alle waren gut gelaunt,   wenn Helmut ins Büro kam.
     
Wenn Helmut ins Büro kam,   waren alle gut gelaunt.
Subordinate clause   Main clause

 

Examples:
Obwohl sie Geburtstag hatte, hat Anna gearbeitet.
Warum sie so viel gearbeitet hat, weiß Anna nicht.
Damit sie ihre Ruhe hat, hat Anna nichts von ihrem Geburtstag erzählt.
Weil Anna keinen Kuchen mitgebracht hat, haben die Kollegen sie geärgert.