When do you know when to use either?
There is a difference in context. "Él comía en ese restaurante" means "he ate (frequently) at that restaurant." "Él había comido en ese restaurante" means "he had eaten at that restaurant (frequently until some event happened)." I would use the había to express a period of time: he had frequented the restaurant for two years when the cook ran away with the waitress (so he stopped eating there). I hope that makes sense and is helpful.