The striker netted in the 88th minute as the Black Cats remained just one point above the relegation zone despite a dogged display in east LondonDick Advocaat's first match in charge of Sunderland ended in defeat as Diafra Sakho's late goal sealed victory for West Ham.
Former Netherlands boss Advocaat was appointed as Sunderland's head coach on Tuesday, following Gus Poyet's departure a day earlier, but saw his Premier League debut end in disappointment at Upton Park.
Sakho made the most of slack Sunderland defending in the final minute of normal time on Saturday after the visitors looked to have seen the game out for a draw.
Despite improvements at the back from their 4-0 hammering against Aston Villa last week, Sunderland saw Jermain Defoe waste their best first-half opportunity, while chances were infrequent after the interval.
Advocaat then opted to introduce Adam Johnson after his club suspension was lifted following an arrest on suspicion of sexual activity with a 15-year-old girl.
The winger failed to inspire his side and it was Sakho who had the final say, extending Sunderland's winless league run to seven matches on a day when fellow strugglers Burnley, Leicester City and Aston Villa were all beaten.
Connor Wickham was the first to threaten for Sunderland as he volleyed at Adrian, although Advocaat was then dealt an early blow with the departure of Wes Brown.
The centre-back appeared to hurt his knee when defending a set-piece and, after he was replaced by Santiago Vergini, Defoe spurned a glorious opportunity against his former club.
Clean through on goal following Steven Fletcher's flick-on, Defoe blazed high and wide before Costel Pantilimon was required to keep out strikes from Kevin Nolan and Alex Song either side of the half-hour mark.
Having seen his side labour in the first half, Sam Allardyce opted to replace Matt Jarvis with Carlton Cole at the interval - though it proved to have little impact.
Sakho headed wide of Pantilimon's right-hand post early in the second half, but a lack of quality on show from both sides made for a poor spectacle.
Fouls and stoppages continued to punctuate play, although West Ham felt they should have had a penalty when Nolan was brought down in the area by Vergini.
However, the referee waved away protests, citing an offside flag in the build-up, as West Ham continued to press as they sought to pick up their first league win since mid-January.
Following Johnson's introduction, Sunderland looked livelier - Patrick van Aanholt testing Adrian from distance - although the winger almost gave away a penalty when he appeared to handle Mark Noble's cross.
Allardyce's side ultimately claimed the points when Sakho latched on to Noble's header, steering a shot into the far corner to give Advocaat plenty to mull over as he seeks to keep the club in the division.