The trio is supporting Food Revolution Day, an annual initiative aimed at children and founded by Oliver, by writing the track and releasing it free of charge.
Sheeran co-wrote the song, which is due for release in May (15), while MCCartney worked on the backing music.
Other stars tipped to take part in the project include Paloma Faith and Chris Martin.
Oliver tells Britain's Daily Mirror newspaper, "I got an email this morning to call Paul, he's just put down bass on lyrics on a special anthem that I've written for Food Revolution Day. I wrote it with Ed Sheeran. It'll go out in beginning of May, viral campaign. We laid down the tracks and Ed set me the task of going out and getting the band together so I said to Paul, 'Will you lay down the bass and he said yes!"
Speaking on Australia's Nova FM radio he adds, "In doing this song with Ed, nobody has actually said no yet. It is pretty amazing. Paloma Faith, Jazzie B from Soul II Soul is doing spoken word, Chris Martin is putting some keys down. Ultimately it comes down to kids and food so I think we can get a great message out there. The weird thing is the poorest communities in the world cook the most incredible food so a lot of it comes back to education."
Food Revolution Day takes place on 15 May (15) and calls for a compulsory food education module to be added to school curriculums in 146 different countries.