This is something that as you use them more, they will come more naturally, but there are a few ways to remember them. In general, the preterite is use for a past action that has been completed and is finished. In other words it is used for an action that you can say has definite beginning and end.
For example: Ayer fui a la playa
However, for the most past, the imperfect is used when an action happens over a period of time and there is not a definite ending. A good example of this would be:
"Cuando era jóven normalmente iba de vacaciónes en Francia."
If you find yourself stuck witth what to use, particularly in a writing exam, there a time phrases you can remember to differentiate. For example you would use the preterite for: anoche, el otro día, anteayer, el ano pasado, esta mañana, en ese momento, but you would use the imperfect for: a menudo, frecuentemente, a veces, todos los años.