The 35-year-old became the greatest sailing Olympian of all time last week when he won the Finn class at Weymouth - his fourth consecutive gold medal at successive Olympiads and the fifth consecutive Olympic Games he has secured a medal.
Ainslie won the first of his history-making medal haul - a Laser class Silver - as a 19-year-old at Atlanta. He then won three consecutive golds at Sydney 2000 (Laser), Athens 2004 (Finn) and Beijing 2008 (Finn).
Ainslie said: "It's a really proud moment for me and for sailing to have such an involvement at the end of what has been such an amazing Games for the whole country.
"There have been so many people involved in making these Games so special, so I think one thing you'd say on behalf of all the athletes is thanks so much to everyone involved - all the volunteers, and the whole nation for getting behind the team.
"It's been our best-ever performance at the Olympics, and I think a lot of that comes down to having so much fantastic home support."
Team GB's chef de mission Andy Hunt added: "Ben Ainslie is the perfect choice for Team GB's flag bearer for the closing ceremony. He has been at the heart of Great Britain's Olympic endeavours since 1996 and his achievements are already legendary.
"There are a number of worthy candidates from Team GB's ranks, athletes who have made the country proud and distinguished themselves through their accomplishments here at London 2012.
"But in becoming the most decorated sailor in Olympic history, Ben has earned the honour of leading our delegation into the closing ceremony of these extraordinary Games.
"As we pass the Olympic baton on to Rio, we as a team are privileged to have Ben lead the way."
In claiming gold at London 2012, Ainslie also overcame Dane Paul Elvstrom's record of four golds in consecutive Games.
He also matched the record for most Olympic sailing medals of any colour, previously held by Torben Grael of Brazil who managed two golds in 1996 and 2004, silver in 1984 and bronze in 1988 and 2000.
- Ben Ainslie
- Olympic sailing