England goalkeeper Foster allowed a powder-puff shot from substitute Carlton Cole to squirm through his legs after Obinna looked to have cost the Hammers dear by crazily kicking Sebastian Larsson in the groin.
Rightly sent off, Obinna had been central to a sterling first half from the home side, which saw Mark Noble deservedly put them ahead, arguably with the help of another Foster error.
Former West Ham trainee Liam Ridgewell levelled after the break and Blues looked destined to go on and win before Foster's howler.
The prospect of West Ham's first League Cup final for 30 years had failed to quell the speculation over Grant's future, with some reports suggesting even a win tonight would not be enough to spare him the axe.
Despite Blues being only two points clear of the Hammers, manager Alex McLeish was under no such pressure as he looked to lead them to their first final since 2001.
But his team did not start like that as West Ham bossed the first half virtually from start to finish.
Captain Matthew Upson set the tone from the unfamiliar position of left-back, an inspired selection by Grant as he bombed forward at will.
The former Blues defender even forced the first of a number of uncomfortable saves from Foster, with a rising near-post drive after his own cross had come back to him off Obinna.
At the other end, Craig Gardner sidefooted straight at Robert Green from 20 yards and that was as good as it got for the Blues before Noble pounced in the 13th minute.
The midfielder's run and cross found Obinna, whose header was cleared off the line before finding its way back to Noble, who lashed in from the narrowest of angles with Foster's view blocked by team-mate Scott Dann.
West Ham, who thrashed Manchester United 4-0 in the previous round, should have added to their tally before half-time.
The marauding Jonathan Spector's piledriver was punched behind by Foster, who then produced acrobatics to tip over James Tomkins' header from the resulting corner.
Foster brilliantly pushed Obinna's near-post drive behind following a swift break, Freddie Sears volleyed Julien Faubert's cross wide and curled over from 25 yards.
Dann nodded over a free-kick as Blues pressed for the final five minutes of the half, but the defender pulled up moments before the break with what appeared to be a hamstring injury and left the field on a stretcher.
He was replaced by David Murphy during the interval, which must have included a McLeish rocket because Blues emerged a different side.
They could easily have levelled when the unmarked Cameron Jerome made a complete hash of a corner from Larsson, who looks set to join Newcastle this week.
Jerome almost made amends in the 55th minute when his bullet header from Larsson's corner was cleared off the line by Sears, who moments earlier had miscontrolled Faubert's deflected cross at the other end.
West Ham failed to heed the warning and another Larsson corner a minute later saw Ridgewell get in front of his marker to power home.
Obinna then pressed the self-destruct button and, after briefly consulting his assistant, referee Phil Dowd brandished a red card.
Ridgewell might have scored a second but strayed narrowly offside heading too close to Green, while Upson looked lucky not to concede a penalty after shoving over Barry Ferguson.
Grant threw on Cole and Zavon Hines for Frederic Piquionne and Sears before Murphy flicked Larsson's latest cross wide.
The 10 men finally managed a shot through Winston Reid's weak effort and, amazingly, retook the lead 12 minutes from time when Cole's even tamer effort from Spector's cross went through Roger Johnson's legs and under the hapless Foster.
Blues replaced the ineffective Alexander Hleb with Jean Beausejour, and Larsson with Nikola Zigic, the latter nodding just wide in the closing moments as the visitors poured forward.