The former Arsenal man has enjoyed an excellent first season on Wearside since joining on a free transfer from Birmingham, featuring 39 times for the Black Cats and scoring eight goals.
"Seb has been complaining of pain for some weeks now - he's really been sore," O'Neill told Sunderland’s official website.
"He has got through the games but it's been a bit of a problem for him and he hasn't been able to train properly.
|Arsenal strikers to discuss futures
"Seb was going to wait until the end of the season [to have surgery], but then he wouldn't have got anything done with the Euros in mind."
O’Neill was full of praise for Larsson’s attitude, and believes that a chance to represent his country at the European Championships would be a fitting reward for his hard work.
He added: "I thought that he has really put the effort in here and he deserved to try and get himself right for the Euros.
"It [the decision] was really down to myself. Seb was really prepared to play through it but his efforts over the last few months have been fantastic so we will try and do without him for the last few games.
"Having the surgery now gives him the chance to be properly fit for the Euros and then have some sort of summer break before coming back to us fresh and ready for the start of next season."
Sweden are in England’s group at this summer’s tournament, and will kick off their campaign against hosts Ukraine on June 8.
How do you stay up to date with football when on the move? With http://m.goal.com – your best source for mobile coverage of the beautiful game.