The song will play during the end credits of the live-action and animated film, which is set to hit theaters July 31.
"I have always loved the Smurfs as a kid and now my boys are the biggest Smurfs fans EVER. I wanted to surprise them with a song in the movie. I know they'll think it's Smurftastic," Spears, the mother of two school-age sons, said in a statement Wednesday.
"We are completely thrilled to have Britney involved with 'The Smurfs.' She is an amazing artist and her boys are Smurfs fans, so it's a great fit for all of us," said Lia Vollack, president of Worldwide Music for Sony Pictures.
"I am very excited that Britney is joining our smurfy adventure. 'Ooh La La' is the perfect Smurf-party song, and the perfect button on the film for audiences around the world," "Smurfs 2" director Raja Gosnell said.
Swim Week Miami Beach 2014 [PHOTOS]