Porc vs. cochon

The French words 'porc' and 'cochon' are often used interchangeably to refer to a pig, but they differ in context and usage.

Porc

'Porc' is used more often to refer to the meat of the pig or swine that is consumed as food.
J'aime manger du porc.
(I like eating pork.)
Le porc est une viande populaire dans de nombreux pays.
(Pork is a popular meat in many countries.)
Nous préparons un rôti de porc pour le dîner.
(We are preparing a pork roast for dinner.)

Cochon

'Cochon', on the other hand, typically refers to the animal itself rather than its meat. It may also be used pejoratively as an insult or in idiomatic expressions.
Le cochon est dans la ferme.
(The pig is on the farm.)
Ne sois pas un cochon !
(Don't be a pig!)
C'est cochon de ne pas se laver les mains.
(It's dirty not to wash your hands.)

Summary

'Porc' and 'cochon' both refer to a pig, but 'porc' primarily refers to its meat while 'cochon' refers to the animal itself or is used pejoratively or idiomatically.