Look at this sentence: I made myself a cup of coffee when my sister came home...
One interpretation of this sentence is: I waited, and when (=as soon as) my sister came home, I made myself a cup of coffee, and offered her a cup too. By using a comma, there is another possibility: I made myself a cup