Both sides lacked spark in a dire fifth-round clash with precious few chances in normal time at Old Trafford.
But McTominay finally relieved the tedium with a sharp low shot from Marcus Rashford's clever set-up in the 97th minute.
United badly missed the creative flair of Bruno Fernandes, who came off the bench in the 73rd, although they did fashion the only real chances in normal time with Lukasz Fabianski making good saves from Victor Lindelof and Rashford.
West Ham, for whom David Moyes is still looking for his first win back at Old Trafford as an opposing manager, created next to nothing although Craig Dawson failed to connect with a header in front of goal in the last seconds of normal time.
The visitors were not helped by injuries with Issa Diop, who replaced Angelo Ogbonna early on, forced to leave the pitch after a clash of heads with Anthony Martial.
Diop was replaced by 'concussion substitute' Ryan Fredericks at halftime -- the first such substitution in English football since the start of a new rule designed to protect player safety.
That was one of the few talking points in a game that never lived up to its pre-match billing.
"I think we got about 15 to 17 shots in the end but we need to be more clinical," United manager Ole Gunnar Solskjaer said.
"We should have finished the game off earlier and finished in 90 minutes but sometimes it doesn't happen.
"We needed to have a good result and a good feeling after today because we were low after the Everton game. It's hard to take but they were really focused and did the job."
Solskjaer's side, who conceded a last-gasp equaliser on Saturday against visitors Everton in the Premier League, dominated possession but struggled to do much with it.
Fabianski did well to turn Lindelof's header onto the post in the first half while in the second he reacted superbly to smother Rashford's effort.
Solskjaer eventually sent influential midfielder Fernandes on to try and shake things up but it was fellow substitute McTominay who settled the tie.
When Declan Rice gave the ball away on a rare West Ham foray, United surged forward with Fred's cross eventually half-cleared to Rashford who had the vision to tap the ball inside for McTominay to fire home from 12 yards.
West Ham huffed and puffed but rarely looked like dragging the tie into a penalty shootout.
"That was really hard to take because the players played brilliantly well," said Moyes.
"We lost a few players during the game and that was difficult. I don't think we deserved to lose the game. We warranted the chance to go to penalty kicks."