Two urine samples taken from the Belarussian before and after her win last Monday tested positive for metenolone, the International Olympic Committee said in a statement on Monday, the day after the Games ended.
"Ostapchuk...is disqualified from the women's shot put event, where she had placed first (and) is excluded from the Games of the XXX Olympiad in London in 2012," the statement said.
Belarus had been ordered to return Ostapchuk's gold medal which would now be awarded to New Zealand's Valerie Adams, who also won in 2008, it added.
Russian Evgeniia Kolodko would move up to silver and China's Gong Lijiao would get bronze.
Ostapchuk, who had won the gold with a throw of 21.36 metres, was world champion in 2005 and European champion two years ago. In July, at a meeting in Minsk, she threw 21.58, the best outdoor distance in the world since 1998.
On Monday, Ostapchuk denied any wrongdoing, saying she would fight to clear her name.
"To be honest I don't know all the details because I just got this information myself from the internet," the 31-year-old told local media in Minsk.
"It's a complete shock to me because I was tested on July 30 (before going to London). It showed I was clean," she said, adding that she would wait for the Belarusian delegation to return from London before deciding what to do next.
"In total, I've been tested 16 times since April. You must be a complete idiot to take doping just before the competition especially such an outdated drug as a steroid, knowing you're going to be tested not once but probably several times."
Ostapchuk also accused Olympic organisers of prejudice against the Belarusian athletes.
"You all know how we had been treated there, just ask Ivan Tsikhan," she said, referring to the Belarusian hammer thrower, who was prevented from competing in London following a request from the sport's world governing body.
"We must fight for our rights. If we remain silent and accept the punishment, then they will continue to humiliate us."
Tsikhan won the bronze in Beijing four years ago but was stripped of the medal after tests showed his testosterone levels were above acceptable limits.
Tsikhan and his team mate Vadim Devyatovskiy, who won silver in Beijing and also had his medal taken away, successfully appealed to the Court of Arbitration for Sport (CAS) in 2010 against their sanctions.
"From the start our athletes had to fight against either judging bias or something else," Ostapchuk said.
"I was closely watched by Olympic drug testers, especially after what had happened to Tsikan. I was tested twice more in London but I don't have any idea how this thing ended up in my body. I'm going to fight this allegation because it can't be possible," she added.
Adams said she was delighted to be promoted to gold.
"I am speechless with this news. It is taking me some time to take this in," she said in a statement.
"It is also encouraging for those athletes like myself, who are proud to compete cleanly, that the system works and doping cheats are caught."
By the start of Sunday's final day of the Games, 11 other athletes had been excluded after testing positive for banned drugs.
They included US judoka Nick Delpopolo, who tested positive for marijuana which he blamed on unwittingly eating a hash brownie, as well as Russian cyclist Victoria Baranova and Colombian runner Diego Palomeque Echevarria, who both tested positive for testosterone.
Officials said urine and blood samples taken from competitors in London would be stored for up to eight years.