There are very few mission profiles in modern (post-WWII) combat that call for "carpet-bombing" of the type that the WWII-era medium and heavy bombers were used for. The primary target of a strategic bombing campaign is typically a city or other highly-populated area. During WWII it was considered a necessary evil, as high-value military-industrial targets were typically located in these cities and the accuracy (and power) of bombs was sharply limited, usually requiring an entire wing of bombers to ensure complete destruction of the target. This approach has since has been eschewed as barbaric by nations with significant air forces.
Technologically, advances have continued to chip away at the heavy bomber's mission profile. Small, precision bombing campaigns have always been given to light bombers like the Stuka, Mosquito and Mitchell, and in later eras the F-100 Super Sabre, F-105 Thunderchief (aka the Thud), A-6 Intruder and A-7 Corsair. These later aircraft used the development of the electronic fire control computer to dramatically increase the precision of unguided weapons, which along with their greater speed against enemy interceptor aircraft rendered the familiar sight of a sky darkened with large bombers unnecessary. In modern warfare, there are few dedicated small ground attack aircraft (the A-10 being a notable exception designed for close air support), most of that going to "multirole" aircraft such as the F-16 and F/A-18, with a few "deep strike" fighters like the F-15E (and when a similar mission profile but more firepower is called for, the B-1B finds its niche). These fighters handle the majority of offensive operations against high-value targets and enemy air defenses ("Wild Weasel" missions), with the A-10, AC-130 and Army helicopters handling the direct threats to infantry and armor.
In the early Cold War era, the best and biggest reason to keep heavy bombers like the B-29, B-48 and B-52 was that they were the only suitable vehicle for the delivery of strategic nuclear weapons (>1Mt). These weapons were phased out of the U.S. arsenal with the introduction of the MIRV-capable ICBM, able to carry the same total payload much farther, faster and with less impact of attrition by defenses, and shortly afte the dissolution of the Soviet Union, the Strategic Air Command itself, the single largest operating authority of the B-52 in history, was dissolved.
The last big reason to have something like a B-52 in theater is the ability to loiter indefinitely (at least 24 hours at a stretch). B-52s have the size and crew space to allow for crew rotations (you're not going to find Stearns and Foster mattresses aboard, but there are a few places to stretch out and kip, and there is a crude lavatory known sarcastically as a "honey bucket"), and with in-flight refueling, the only serious limitations to flight time are the capacity for on-board food stores and the eventual depletion of munitions. The B-52 can be equipped with 336 GPS-guided JDAM weapons, and a B-52 loitering at 50,000 feet over a theater like Afghanistan can be directed via AWACS/JSTARS to drop a guided bomb at a target with no visual line-of-sight needed. If air defenses are a potential problem, it has far-BVR capabilities when using cruise missiles like the JSOW, though it can carry fewer of them. This is the B-52's last stronghold, and it's a significant one; given various upgrades for efficiency and technological improvement during its life, the USAF plans to maintain a modest number of these aircraft until at least 2040.