Danny Gabbidon headed home in the 80th minute before subsititute Zavon Hines added a second in injury time to complete the victory.
The Hammers made four changes from the side that lost to Tottenham with Jonathan Spector, Gabbidon, Mark Noble and Scott Parker all handed starts.
A minute’s silence was held before kick-off in honour of Sir Bobby Robson, who passed away earlier on Friday.
The Irons bossed the game and took the lead when Gabbidon broke free of his marker to send a towering header home from Noble’s corner.
In stoppage time, Hines sprinted clear of the defence before firing a low shot underneath the goalkeeper and into the back of the net.