The hosts trailed after just eight minutes through Maya Yoshida's towering header, before Matthew Jarvis was played in by Kevin Nolan to level things with a tidy finish, despite there being a hint of offside.
There were no doubts over West Ham's second three minutes later, though, with fan-favourite Cole heading Stewart Downing's corner against the post before tucking away the rebound.
The win was wrapped up in the 71st minute courtesy of Nolan's superb overhead kick, much to the delight of manager Sam Allardyce.
|VIEW FROM UPTON PARK
|By Harry Sherlock at Upton Park
What a remarkable victory for West Ham. Southampton took an early lead and looked in control, with Adam Lallana running the show in the opening exchanges.
The Hammers fought back, however, and thoroughly deserved their comprehensive victory. Kevin Nolan, in particular, was exceptional and Sam Allardyce will be delighted. An utterly stunning win.
And a confident start by the visitors was rewarded early on when Steven Davis' whipped free kick from the right found Yoshida, who rose highest to power home from eight yards.
West Ham, unchanged from the 2-0 win over Norwich City, almost hit back immediately, after Guy Demel's low cross eventually found its way to Nolan, who could only stab his effort straight at Artur Boruc.
The captain made amends just 10 minutes later, producing a wonderful ball over the top of the defence for Jarvis, who beat the offside trap to round the keeper and tap home, despite replays suggesting that the winger may have been offside.
West Ham looked to be in the ascendency and took the lead three minutes later when Southampton failed to deal with Downing's corner, allowing Cole to head onto the post before lashing home from close range at the second attempt.
A shell-shocked Southampton struggled to regain their early momentum, but nearly restored parity just after the half-hour mark when Rickie Lambert rose to meet Jack Cork's cross from the right, only to be denied by the woodwork.
But there was more controversy just after the break when Jose Fonte's goal-bound header appeared to strike the arm of James Collins, although referee Mark Clattenburg dismissed calls for a penalty.
Collins was at the centre of proceedings again just before the hour mark, heading Downing's corner just over the bar as the hosts looked to wrap the game up.
They were nearly made to pay for their wastefulness five minutes later, with Adam Lallana failing to get on the end of a wonderful low cross from Luke Shaw, before substitute Gaston Ramirez fired over a minute later.
Southampton continued to press and should have levelled through Lallana, who capitalised on a defensive error to race through on goal yet could only guide a tame effort wide.
But West Ham secured the three points with just under 20 minutes left when Cole's flick-on found Nolan, who produced an acrobatic overhead kick to put the game out of reach.
Substitute Mohamed Diame crashed an effort off the bar late on but a greater deficit would have been harsh on Southampton, who saw a six-match unbeaten league run come to an end.