The correct punctuation is:
"When you go to the grocery store, don't forget to buy cheese."
"When you go to the grocery store" is a subordinate clause (A clause that doesn't give you a complete thought) and you use a comma before the word "don't" because "don't forget to buy cheese" is an independent clause(A sentence which has a subject and a predicate).
:)