A comma is required before or after an adverbial clause, depending on whether it begins or ends a sentence, and if it functions as a nonrestrictive clause. A nonrestrictive clause is not essential for the reader to understand the full meaning of the word or words that it modifies. It simply adds more information, describing but not limiting (“restricting”) what it modifies. (For more info about restrictive and nonrestrictive clauses, see my post “Which hunting.”)
Look at this example:
When Charley woke up a horrible stench filled the room.
I have underlined the adverbial clause. It’s nonrestrictive in this sentence, so you should place a comma after the word up. Then readers won’t misread the sentence and think that Charley woke up a horrible stench.
For the same reason you should put a comma after the adverbial clause in this cannibalistic sentence:
When we had finished eating Robert and I left the room.
Two cannibals are eating a clown. One cannibal looks at the other one and asks, “Does this taste funny to you?”
Thayer Literary Services