In the US an aircraft may be allowed to fly indefinitely so long as it continues to meet the requirements of the definition for "Airworthy" in Court Order 8130 (.2e par 9).
Note: Aircraft operated by government agencies or the military do not
have to comply with any rules, laws, or regulations - they may operate
in any manner the agency desires (as long as they are not used for paying passengers). These aircraft are described in FAR 1.1 as "Public Aircraft". Examples: military fighters and transport, firefighting, research, etc.
There are two possible scenarios for replacing a part.
1) Life Limited: The manufacture or FAA through an AD (airworthiness directive) requires a part to be replaced at a certain limit i.e TIS (time in service) - calendar or operating hours, number of operating cycles (i.e. number of landings or pressurization cycles), etc. The manufacture is required to provide a chapter/section of the POH (Pilots Operating Manual) that list all life limited parts.
2) On Condition: Maintenance personal (often during an inspection) find the part 1) inoperative, 2) near or beyond "Service Limits" published by the manufacture, 3) in the discretion of maintenance personal worn and no-longer safe for operation, deemed not airworthy, etc. These parts are repaired or replaced as needed.
In practice many older aircraft have been completely replaced (technically a "repair"). There is no limit on the amount an aircraft can be "replaced".
War birds are one such example. It is legal to salvage an airplane from the ocean floor, use the corroded metal as a template to make new parts and completely assemble an aircraft from new material. The restored aircraft must be identical to the original aircraft and is legally considered the same aircraft ("all" the parts where repaired!).
There are many examples, such as the P-38 "Glacier Girl" being one of the more recent well document examples. It was salvaged after being crushed under 265ft of glacier ice for over 50 years.