Foster gifts Hammers advantage
The striker came off the bench to turn the match back in West Ham's favour at Upton Park with a simple side-foot finish that embarrassed fellow England international Foster after Liam Ridgewell had cancelled out Mark Noble's early opener.
The home side had Nigerian striker Victor Obinna sent off on the hour for a petulant kick between Sebastian Larsson's legs.
Victory was a boost for West Ham manager Avram Grant whose job has been the subject of intense media speculation since a 5-0 thrashing at Newcastle United last week sent the east London club back to the bottom of the Premier League.
"The spirit was great, we have a small squad and have played a lot of games in a short space of time but the players didn't give up," the under-fire Grant told the BBC.
The Israeli would not be drawn on whether he would still be in charge for the second leg at St Andrews on January 26 when the sides will battle for the right to play Arsenal or Championship Ipswich Town at Wembley Stadium.
"I'm not dealing with (my future) you have to ask the person who gives the orders," he said.
"We are one point below Wigan, Fulham and other teams, but with them everything is quiet," added Grant, who took Portsmouth to the FA Cup final last season when they were also relegated.
"Unfortunately, we have to fight with other things off the pitch. I don't want to think about other things but to fight and take on the challenge."
West Ham, who have never won the League Cup, dominated the first period after Noble's far post blast in the 13th minute squeezed past an unsighted Foster, whose penalty shootout save won the competition for Manchester United two years ago.
The keeper had kept Birmingham in the tie before half-time with several fine saves to stop the home side adding to their lead but the second half was a complete contrast.
The visitors, fired up by a half-time pep talk from manager Alex McLeish, pinned West Ham back and it was no surprise when Ridgewell equalised with a stooping header from a corner. Three minutes later Obinna, on loan from Inter Milan, lost his head and was rightly sent off for catching Swedish midfielder Larsson with a painful kick at a throw-in. Birmingham appeared to be in the driving seat but the introduction of Cole proved decisive when his scuffed winner from Jonathan Spector's low cross with 12 minutes left somehow evaded a distraught Foster. The first leg of the other semi-final is Wednesday.