Older planes are no less safe than modern planes, and there isn’t actually any concept of an old aircraft in terms of aviation. The plane is either operable or inoperable, and any plane that is safe to operate will be just as safe as a new airplane on its first round of flights.
The age of an average aircraft will vary depending on the individual airline, and all airlines will have planes of different ages. As well as this, each airline will have different timelines for how and when it will replace older aircrafts. So, there is no specific age where a plane will be taken out of use, it all depends on the individual plane.
The remaining service life of a plane is measured in years, flight hours, and quantity of takeoffs and landings, and each of these things will be assessed independently. Some aircrafts will become over-aged more quickly than others due to frequent flights of shorter distances.
There are lots of aircrafts that will keep on going after they have been taken out of service. Many of these aircrafts will be used as cargo aircrafts, that will be perfectly operable for many more years after they have stopped being used for commercial purposes. Essentially, the safety and reliability of an airplane will come down to how well the aircraft is taken care of. So, an older aircraft can operate just as safely as a newer one.