Confirming the planned departure of forces, Mr Wallace also warned any attacks on existing troops would be "met with a forceful response".
The UK military has been in Afghanistan since 2001, with more than 450 British troops dying during the conflict with the Taliban and fighters from al-Qaeda.
The US has said it will withdraw all forces by 11 September.
And Nato confirmed allies would begin withdrawing troops from 1 May.
The last UK combat troops left in 2014, but about 750 remain as part of the Nato mission to train Afghan forces.
In a statement, Mr Wallace said: "The people of Afghanistan deserve a peaceful and stable future.
"As we drawdown, the security of our people currently serving in Afghanistan remains our priority and we have been clear that attacks on Allied troops will be met with a forceful response.
"The British public and our Armed Forces community, both serving and veterans, will have lasting memories of our time in Afghanistan.
"Most importantly we must remember those who paid the ultimate sacrifice, who will never be forgotten."
US President Joe Biden has announced that American troops will leave Afghanistan by 11 September, saying it was "time to end America's longest war".
That would coincide with the 20th anniversary of the terror attacks on the World Trade Center and the Pentagon in the US in 2001.
Mr Biden said while the US "will not stay involved in Afghanistan militarily", its "diplomatic and humanitarian work" would continue.
"We cannot continue the cycle of extending or expanding our military presence in Afghanistan hoping to create the ideal conditions for our withdrawal, expecting a different result," he said.
US Secretary of State Anthony Blinken, speaking to Nato allies in Brussels, said: "I am here to work closely with our allies, with the (Nato) secretary general, on the principle that we have established from the start: In together, adapt together and out together."
He added that they would work closely in the coming months "on a safe, deliberate and co-ordinated withdrawal of our forces from Afghanistan".
The new deadline is four months later than the Trump administration previously agreed in a deal with the Taliban.
Our defence correspondent Jonathan Beale says the UK, like most Nato allies, relies on the US's infrastructure, logistics and support in Afghanistan.
The US has some 2,500 troops in the country as part of a 9,600-strong Nato mission.
At the height of the war, Nato had more than 130,000 troops from 50 nations in Afghanistan. The UK had 9,500 personnel and 137 bases in Helmand province alone.
The speaker of the Afghan parliament, Mir Rahman Rahmani, has warned the withdrawal of foreign forces in the current circumstances will lead to civil war.
In February 2020, the US and the Taliban agreed a deal that would see the US and Nato allies withdraw all troops within 14 months if the Taliban upheld its promises, including not allowing al-Qaeda or other militants to operate in areas it controlled and proceeding with national peace talks.
Although the group stopped attacks on international forces as part of the agreement, it has continued to fight the Afghan government.
Last month, the Taliban threatened to resume hostilities against foreign troops still in the country on 1 May.