Both pandemic and epidemic refer to an occurrence in which a disease spreads quickly and affects a lot of people.
An epidemic is an occurrence of a rapidly spreading disease that affects many people. A pandemic, in comparison, is an occurrence of a rapidly spreading disease that affects a large proportion of the population and has spread to many different geographic regions.
A pandemic is a very bad epidemic.
There is no set point at which an epidemic is officially called a pandemic, and so sometimes an outbreak of a disease is called both.
I hope this helps.