They are saved at the ground and labelled as to how many overs they where used for. Then in a future match when a ball is lost or more likely badly damaged as to be unusable the umpire will call for the box of balls and if at all possible will pick one out of the box that is in a similar state in it's life to the one that was lost. I don't know how long they are kept.
That's true RIGeezer, balls are labelled in this way. There will be some balls that are 40-80 overs old because some innings only last that long but there must be lots of balls that last the full 80 overs (i think new ball is after 80,or is it 85 overs?). I'm not sure of the point of keeping all those old balls - when would anyone ever need an 80-over old ball?
well the number of overs is just one of the indicators to help the umpire, in reality they want one in a similar state to the one that was damaged. It is quite common for the 2 captains to also be called for their opinions before the umpire selects a ball.
oh and the ball is not automatically changed after 80 overs, it merely becomes available to the fielding side should they want it. If a bowler is comfortable with the old ball then he can carry on. It must be changed though if it is clearly damaged to such an extent that it no longer fits the law of the game.