The passé composé is used when talking about completed actions in the past. E.g. "Un chien a couru devant moi". The imparfait is used when talking about continuous actions in the past, or as a description of the past. E.g. "Je promenais le long de la route" or "Il était heureux".
A good way to distinguish between the two is when the two are used in conjunction: The imparfait is used to describe a continuous action, and then the passé composé is used to describe a specific event which occured within that or interrupted it. E.g. "Alors que je promenais le long de la route, un chien a couru devant moi."