The hosts took the lead late in the first half when Adam Johnson capitalised on a Hugo Lloris error following an Ondrej Celustka cross.
But Tottenham were level before the break through Paulinho before O'Shea inadvertently diverted the ball past Vito Mannone in the 50th minute to hand the visitors all three points.
Jermain Defoe was also twice denied by the woodwork as Tottenham went in search of a third.
Defeat for Sunderland – a result that leaves them bottom of the Premier League and without a win in four – will be especially difficult to stomach as a Phil Bardsley own goal handed Chelsea a 4-3 win at the same ground on Wednesday.
While Gus Poyet's men face a lengthy battle to beat the drop, his former club Tottenham are sixth.
Sunderland made four changes to the side that lost to Chelsea on Wednesday, with Adam Johnson, Steven Fletcher, Sebastian Larsson and Ondrej Celustka coming in for Andrea Dossena, Craig Gardner, Emanuele Giaccherini and Fabio Borini.
Andre Villas-Boas also made a quartet of alterations from Tottenham's 2-1 midweek victory at Fulham, bringing Kyle Naughton, Mousa Dembele, Lewis Holtby and Nacer Chadli in for Erik Lamela, Sandro and injured duo Jan Vertonghen and Vlad Chiriches.
After a quiet opening 10 minutes, Paulinho had the first meaningful opportunity of the match, sending a dipping effort from distance narrowly over the crossbar.
But it was the hosts who took the lead in the 37th minute, as goalkeeper Lloris made a dreadful attempt to deal with a Celustka cross, palming the ball to the feet of Johnson, who gratefully smashed it into the back of the net for his first goal of the season.
Tottenham, though, were level six minutes later, Paulinho prodding home from close range after Chadli had nodded the ball down from a Holtby free-kick.
Lloris had to be alert moments later as Celustka fired a thunderous effort straight at the goalkeeper from outside the Tottenham penalty area.
Tottenham were ahead five minutes into the second period as Dembele attempted to pull the ball across the face of goal, but got lucky as it deflected into the goal off O'Shea.
The Irishman's own goal came in the same minute as he scored at the right end against Chelsea in midweek.
Defoe headed against the post from an Aaron Lennon cross seven minutes later as the men from North London found their stride. He went close again in 66th minute, but dragged his effort narrowly wide of the left-hand post.
Sunderland had appeals for a penalty turned down in the 75th minute as substitute Sandro handled in the penalty area shortly after being introduced. Replays suggested Poyet's men had every reason to feel hard done by.
Defoe hit the post once again 11 minutes from time before Borini squandered a chance to salvage a draw as Sunderland applied the pressure in the closing stages.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.