This is an incredibly common query, and often the best way to ensure you can fully distinguish between the two is to read, read, read.
As a rule, however, the preterite is used to describe actions in the past that have been completed. For example, when someone asks "¿Que hiciste ayer?" ("What did you do yesterday?") the verb 'hacer' is in the preterite form. This is because they are asking about an action that has been completed - the action specifically occurred yesterday and has since terminated.
Meanwhile, the imperfect describes past actions that occurred repeatedly or were ongoing. For example, if you are discussing "cuando era joven" ("when I was young"), "ser' is placed in the imperfect tense. This is because your youth - although in the past now - was once a habitual, ongoing process and thus is less final than the preterite.