The singer-songwriter, who released his acclaimed third album earlier this month, announced the "awesome" news via a video on Instagram.
He said: "Hello from Ed Sheeran, we're starting the tour off today and I want to make an announcement.
"I am headlining Glastonbury on the Sunday night which is awesome."
Sheeran's stint on the Pyramid Stage on the Sunday means he is tasked with closing the event in Somerset.
The previously-confirmed headliners were Radiohead, who will perform on the Friday night, and the Foo Fighters, who will take to the stage on Saturday.
The 26-year-old has performed at the festival a couple of times before, but not as a headliner. His first appearance was in 2011 on the Croissant Neuf stage, as well as the BBC Introducing Stage, ahead of the release of his debut album. Sheeran returned in 2014 with an early-evening set on the Pyramid Stage.
This year's event, held between June 21 to 25, is expected to attract around 170,000 people.