The above posts are correct.
Also there are tools to measure chain and cog wear.
Measuring the chain (under tension) should be a regular part of maintenance.
12-1/16 = replace chain 12-1/8 = replace cogs.
Chains are much cheaper than cogsets so as a rule I replace all my chains every year (whether I rode the bike much or not)
If you must milk the life of a chain, keeping it clean and lubed will extend the life and prevent pin wear (sometimes called stretching).
See Sheldon Brown's site for details.
Enjoy