Lifetime limit depends on the design and on usage.
Many aircraft have a lifetime limit given in cycles (i.e. number of takeoffs and subsequent pressurization cycles). For the B-52, flight hours are used instead (because the fuselage isn't pressurized).
Modern aircraft are designed to a specific limit, and modern CAD software allows you to predict this pretty well so the aircraft becomes no heavier than it needs to be. The B-52 didn't benefit from this, so it was overbuilt.
The move from high-altitude to low-level operations shortened fatigue life. Various modifications were carried out to strengthen the wing, for instance:
Intensive structural testing, conducted by Boeing and the Air Force in 1960, again confirmed that hard usage shortened the structural life of the B-52 aircraft. The B-52Gs and B-52Hs differed significantly from predecessor models, but design changes incorporated in the new bombers made them even more susceptible to fatigue damage. Briefly stated, the changes had been made to extend the aircraft's range, which essentially meant that while the B-52G and B-52H bombers were lighter than preceding B-52s, their fuel loads had been increased. Moreover, the overall decrease in structural weight had been achieved primarily by using an aluminum alloy in the aircraft's wings. While testing did not question the intrinsic strength of the wing, it pinpointed areas of fatigue. No one could forecast accurately when the wing failures would happen, but low-level flying and the structural strains that occurred during air refueling were expected to speed up fatigue considerably. It was estimated that under fairly similar circumstances, the operating stress placed on the new wing was approximately 60 percent higher than the stress inflicted on the wing of preceding B-52s. The anticipated problem appeared serious enough for SAC to impose stringent flying restrictions on the new aircraft, pending approval of necessary modifications. In May 1961, the Air Staff endorsed a $219 million modification program for all B-52G and B-52H wing structures. The wing structural improvement program, carried out as ECP 1050, replaced the wing box beam with a modified wing box that used thicker aluminum. It also installed stronger steel taper lock fasteners in lieu of the existing titanium fasteners; it added brackets and clamps to the wing skins, added wing panel stiffeners, and made at least a dozen other changes. Finally, a new protective coating was applied to the interior structure of the wing integral fuel tanks. The program provided for Boeing to retrofit the modified wings during the airplanes' regular IRAN schedule, except for the last 18 B-52Hs, which would get their modified wings on the Wichita production lines. Started in February 1962, the program was completed by September 1964, as scheduled.
According to GlobalSecurity:
Current engineering analysis show the B-52's life span to extend beyond the year 2040. The limiting factor of the B-52's service life is the economic limit of the aircraft's upper wing surface, calculated to be approximately 32,500 to 37,500 flight hours. Based on the projected economic service life and forecast mishap rates, the Air Force will be unable to maintain the requirement of 62 aircraft by 2044, after 84 years in service.
The B-52H was designed as high altitude aircraft, but was adapted to low level tactical maneuvers in 1960's. A number of structural improvements were made during the 1960s and 1970s to equip it to fly the more demanding low- level mission and to address other structural issues.
The airframe life for the current fleet is estimated to be between 32,500 and 37,500 hours, depending on the usage history of the individual aircraft. The estimate is based upon scaling measurements from a full-scale test structure using assumed mission profiles along with historical and projected usage information. The upper wing surface is expected to be the life- limiting structural member. As of 1999 the average airframe had 14,700 flight hours. Boeing believes with high confidence that the average number of flight hours left is 17,800, at a minimum. The "oldest" B-52H is at about 21,000 hours and only experiences about 380 flight hours per year.
Boeing makes an estimate of airframe life using fatigue testing on a test airframe, and/or modern CAD.