© AP Photos
Victory sees the Wearside outfit pull six points clear of the Premier League relegation zone.
It stayed that way until the break, but Adam Johnson pounced from close range two minutes after the restart to stretch the Black Cats' lead.
© PA Photos
Steven Fletcher had a goal chalked off by the linesman's flag, but the points were wrapped up by James McClean with 15 minutes left on the clock.
The Irish winger connected with Stephane Sessegnon's driven cross for his second goal of the season.
The result leaves the Hammers perched in 11th place.