When to give your body a rest and when to push through

A question that I see come up often in any kind of forum linked to fitness is if you should work out despite feeling sore or if you can still work out despite having a cold or the flue.