I replace them before they get that far gone. I always leave on tour with new or nearly new tires. If you're on the road and find you need a new tire, get it. Don't try to make it back home on a excessively worn tire. When you buy a tire look at the date of manufacture and don't get a tire that's too old.
All tires have a number molded into their sidewall.
Make sure the tire has the proper load rating for your bike. Buy the right size tire for your bike. A lot of people, especially guys on older sport bikes, want to buy a big fat rear tire so that they can look like the racers. This is dangerous. If you put too wide a tire on a wheel the tire will have the wrong shape.