The 33-year-old club captain, who moved to the Black Cats from Manchester United back in 2011, is now tied down to the Premier League club until 2017.
Head coach Gus Poyet told the club's official website: "I am delighted that John has agreed to stay with us for at least another two years.
"He is our captain, one of our leaders and I am sure he will continue to help us get better and stronger as a team. I really look forward to continuing to work with John."
The news comes after O'Shea scored a vital equaliser against world champions Germany in his 100th appearance for the Republic of Ireland on Tuesday.