Which answer is correctly punctuated?

On our way to the beach we, had to stop and buy sunscreen.

On our way to the beach, we had to stop and buy sunscreen.

On our way to the beach we had to stop and buy sunscreen.

On our way, to the beach, we had to stop and buy sunscreen.

The correctly punctuated answer is:

"On our way to the beach, we had to stop and buy sunscreen."

The answer that is correctly punctuated is:

"On our way to the beach, we had to stop and buy sunscreen."