My rule of thumb is that you shouldn't go to the gym if you're sick enough that you wouldn't want someone as sick as you in the gym if you were well (got that?
. I'll often go for a walk or maybe a jog if I have a cough, but I try not to spread my germs around in the confined quarters of a gym or locker room.
That being said, sometimes it's better just to give your body a chance to rest up. When I'm sick and try to work out anyway, I often regret it because I can't lift as much as usual or my endurance goes to he** or I have no energy. There will always be tomorrow...