The answer, like so many related to chickens is, 'it depends'.
You don't have to get rid of your chickens. If they're pets a chicken can live to be 10 or more.
If your primary purpose for a chicken is getting eggs they continue to lay relatively reliably (though individual hens can vary) up to about 5...some breeds are better than others about this.
If you are selling eggs commercially, most hens experience a severe downswing in the number of eggs after about 3 years. Commercial battery hens are changed out as often as 18 months but that's really a bit excessive for backyard chickens.