They will join the 450 British troops already in the country - and will aid counter-terrorism efforts and provide leadership training.
Officials have said the additional troops will not be taking part in combat operations against the Taliban.
UK troops had been due to leave Afghanistan this year but will now have their mission extended into 2017.
Announcing the deployment at a Nato summit in Warsaw, Mr Cameron said it was essential that Nato continued "to work with the Afghan government and the Afghan security forces to help keep terrorists out of that country".
He said the "UK would do more to train Afghan officers" while deploying "a further 50 personnel to provide additional mentoring, particularly to the Afghan air force".
He also announced MPs will vote on replacing the ageing submarines carrying the Trident nuclear missile system on 18 July.
It comes after US President Barack Obama this week announced a slowdown in the US military withdrawal from Afghanistan.
Of the additional UK troops to be deployed, 21 will join the counter-terrorism mission, 15 will be involved in a leadership development at the Afghan army's officer training academy, and 13 will join Nato's Resolute Support Mission.
In addition, Britain is to extend its Â£70m a year funding for the Afghan security forces to 2020, committing an extra Â£178m to the Afghan government of president Ashraf Ghani.
Mr Cameron said the deployment underlined his determination that Britain should continue to play a leading role on the world stage despite the referendum vote to leave the European Union.
"Britain is not going to be playing a lesser role in the world. We will make sure that we use our strength, including through Nato, to spread British values and the things that we believe in," Mr Cameron added.
The prime minister also emphasised that President Obama had told him Britain would continue to be a reliable, strong ally outside the European Union.
It comes after it was announced that a 500-strong battalion of UK troops will be deployed to Estonia and 150 troops will go to Poland as part of the Nato response to concerns over Russia.
Earlier this week, Mr Obama told reporters that the security situation in Afghanistan remained "precarious", with the Taliban still mounting suicide attacks in the capital Kabul and other cities.
"Instead of going down to 5,500 troops by the end of this year, the United States will maintain approximately 8,400 troops in Afghanistan into next year through the end of my administration," Mr Obama said.
"It is in our national security interest, especially after all the blood and treasure we've invested over the years, that we give our partners in Afghanistan the best chance to succeed," he added.
The UK is to send up to 50 additional military personnel to Afghanistan to train and advise security forces there.