The 22-year-old, who has written "I see fire" for the film, almost missed the project, reports contactmusic.com.
"I was off my face drunk. There was a lot of champagne and champagne gets me drunk quite quickly. I looked at my email. It was like a dream. I didn't process it. So then I put my phone away and continued partying," Daily Star newspaper quoted Sheeran as saying.
Directed by Peter Jackson, the film starring Martin Freeman, Richard Armitage, Ian McKellen, Evangeline Lilly, Orlando Bloom, Lee Pace and Luke Evans, is the second film in the Hobbit trilogy after "The Hobbit: An Unexpected Journey", which came out in 2012.