I would say keep the car until it blows up, you destroy it, someone steals it, or it falls apart. However, that's not always practical.
I say keep it until there's major repairs needed. "Major" being defined as new/rebuilding engine/transmission or similar, if you can't do the work yourself, or if the parts are prohibitively expensive. Any "long term wear" items such as a radiator, muffler, or brakes, I would replace without even thinking about it. This of course all goes more smoothly (and cheaper) if you can do the work yourself, or find a friend to help you out. A rule of thumb for expensive repairs that I read somewhere is $100/1000 miles. Meaning, if you think a $100 repair will get you at least another thousand miles, it's "worth it". $1000 for 10,000 miles of extra life, etc. This basically factors a $0.10/mile maximum "depreciation" on the repair to extend the life of your car. Not saying it's perfect, but it's a good way to quantify the relative cost of expensive repairs.