I've always stopped when my muscles are moderately sore, but I've seen some people on this site say that soreness is not an accurate gauge of how good of a work out you got. How do I tell when my body's had enough?
I think the standard approach to training is to have a set of goals (better health, better in a specific sport, recovery from some injury, etc.) that you've set and you gear a training program/schedule to accomplish that. The schedule is developed to guide you to your goal in a given time without causing additional injuries. For some people the schedule/workout takes you beyond the point of soreness and for others it's prior to reaching that point. The schedule/plan could be time based (x minutes on a bike) or effort based (x sets/reps).
So, you should stop when your set plan dictates. In other words, don't go into an exercise program with an open ended 'work till I drop' type of plan because it will most likely result in injury and a very short term engagement.
If during a well planned schedule you feel ill, out of sorts, weak, etc. - much different from prior exercise sessions - you should also stop.
The problem with stopping when you're sore is you don't always know until it's too late. Many times I've engaged in full contact sparing sessions where one or both of us ends up with blood all over our uniform. Usually, we have to examine each other just to find out whose blood it is. Obviously, if we had felt anything we would have stopped earlier. I'm sure it's the same with many activities: lifting weights, riding a bike, swimming, ect. You're probably on a adrenaline high and have exercise induced endorphins clouding your senses.
The way you know when to stop exercising is simple: you've finished your planned work out for the day. If you weight lifting you should choose the exercises and choose the weights and rep you're going to do even before stepping foot in the gym. If you're running, biking, or swimming then you should choose a distance. If you're working with a coach he will know if you're going to hard or fast, trust his judgement. Stick to a plan, it'll keep you from working too hard and from injuring yourself by trying something foolish. If you end up getting sore then adjust your plan for the next exercise session.
The obvious exception to my statement above is if you feel pain during the exercise. In that case you should always stop immediately. Check your form, check your pace, and check your weight. Make sure everything is fine and the pain hast left before starting again.