For this question we will use the verb manger (to eat) as an example.
The perfect tense is used to describe an action which took place once in the past. You can think of it as a single, completed action.
EXAMPLE: Hier soir j'ai mangé une pizza au restaurant.
TRANSLATION: Last night I ate a pizza at a restaurant.
So, last night you ate pizza - let's say it was a one-off occasion.
Now, if you want to describe something in the past that you did regularly, you will need to use the imperfect tense. Think of this as a repeated action done during a period of time.
EXAMPLE: Quand j'etais petit, je mangeais chez ma grand-mère chaque dimanche.
TRANSLATION: When I was little, I used to eat at my grandma's every Sunday.
The key words here are "used to" and "every". If in English you would use "used to" and "every" in your sentence, you will need to use the imperfect in French.
The imperfect is also used when talking about something which went on for some time - let's say, a continuous action.
EXAMPLE: Je mangeais mon repas du soir quand il m'a appelé.
TRANSLATION: I was eating my dinner when he called me.
So, you were in the process of eating your dinner when he called.
REMEMBER:
I ate = j’ai mangé (perfect)
I used to eat = je mangeais (imperfect)
I was eating = je mangeais (imperfect)