Letterman, 66, whose contract expires next year, began hosting the CBS show in August 1993, after leaving the rival NBC network, where he originated his late-night TV persona and much of his program on the "Late Night with David Letterman" show for many years.
There was no immediate word on who might succeed Letterman in the key 11:30 p.m. slot on CBS, opposite NBC's top-rated "The Tonight Show."
The Emmy-winning host said he had spoken in the past with CBS Corp President and Chief Executive Officer Leslie Moonves, "and we agreed that we would work together on this circumstance and the timing of this circumstance.
"And I phoned him just before the program, and I said, 'Leslie, it's been great, you've been great, and the network has been great, but I'm retiring,'" Letterman told his studio audience, according to a CBS transcript.
"We don't have the timetable for this precisely down - I think it will be at least a year or so, but sometime in the not-too-distant future, 2015 for the love of God," he added.
CBS said Letterman's announcement elicited a standing ovation from the audience in the Ed Sullivan Theater.
Letterman's impending departure from CBS marks the latest in a recent rearrangement of the late-night deck chairs at the major networks.
News of Letterman's plans to retire came nearly two months after Jay Leno bid farewell as host of NBC's "The Tonight Show," a job Leno assumed in 1992 in a bitter and highly publicized succession of Johnny Carson that led to Letterman's defection from NBC.
Leno was replaced by Jimmy Fallon, who had hosted the show that airs after "The Tonight Show," and Fallon in turn was succeeded by comedian Seth Meyers, who like Fallon is an alumnus of "Saturday Night Live."
Letterman, a late-night fixture for three decades, had jumped ahead of "The Tonight Show" in the ratings as recently as 2010, when "Tonight" was briefly hosted by Conan O'Brien.
RIVALRY AND INNOVATION
Fallon's show averaged 5.1 million viewers a week, compared with 2.9 million for Letterman, according to Nielsen.
Although "Late Show" trailed "Tonight" in the ratings war, Letterman long reigned as the critics' favorite, known for an edgier, irreverent brand of humor and signature bits like "Stupid Pet Tricks" and the nightly Top-10 list poking fun at current events and pop culture.
He also was a practitioner of such innovations as the "Monkey Cam," in which a TV camera was strapped to a monkey turned loose in the studio; a bit where he dropped objects such as melons and television sets off a high platform and played the results back in slow motion; and stunts such as throwing himself onto a Velcro-covered wall or dunking himself in a pool dressed in a suit covered in Alka-Seltzer tablets.
But his show had its more sober moments as well. Veteran CBS newsman Dan Rather famously showed the strain of reporting on the suicide hijacking attacks that destroyed the World Trade Center when he choked back tears during a guest appearance for Letterman's first broadcast after the Sept. 11, 2001 disaster.
Moonves said in a statement that Letterman "managed to keep many celebrities, politicians and executives on their toes - including me."
The Indianapolis native began his CBS career after 11 years as host of NBC's "Late Night" program in the time slot immediately following "The Tonight Show with Johnny Carson" at 12:30 a.m., and was long considered Carson's likely successor.
But when Carson retired in 1992 after nearly 30 years of hosting "Tonight," NBC replaced him with Leno, sparking a very public, bitter feud with Letterman.
The following year, Letterman jumped to CBS to go head to head against Leno and his old network in the flagship 11:30 p.m. time slot, setting up one of the most storied rivalries on U.S. television.
He brought his bandleader and sidekick Paul Shaffer with him to CBS, but the name of the ensemble was changed from the World's Most Dangerous Band to the CBS Orchestra.
Letterman led the ratings for his first two years at CBS, but Leno rose to No. 1 in 1995 and stayed on top for much of the rest of his tenure.
In March 2002, the Walt Disney Co.-owned ABC network made a bid to woo Letterman away from CBS in an aborted effort to replace ABC's late-night news program, "Nightline," but Letterman ultimately opted to stay put at CBS.