The deal, reported to be worth up to £5m, will feature Beckham supporting Sainsbury's Active Kids campaign, which encourages children to lead a healthier lifestyle.
He will also support the supermarket's sponsorship of the London Paralympic Games, alongside existing ambassador Ellie Simmonds, a Paralympic swimmer.
Beckham's partnership with the supermarket will kick off with an in-cinema advert on 25 November.
Justin King, Sainsbury's chief executive, said: "We're thrilled to have David on board as an ambassador of our Active Kids campaign.
"As a world class athlete and father of four, David is the ideal ambassador to support our commitment to encourage children to get active and live healthier lifestyles for less money."
The partnership was negotiated by Simon Fuller's XIX Entertainment.
Beckham, who plays football for Los Angeles Galaxy, has received huge amounts in sponsorship deals, which have included tie-ups with Vodafone, Gillette and Adidas.
Oliver, who has been the Sainsbury's ambassador for more than 11 years, announced his decision to leave the role in July.
Follow Sophie Maden on Twitter @Sophie_Maden