Yes. Danny Pink did indeed work and fight in Afghanistan. It was his military time there which soured him on war and he retired after accidentally killing a young boy.
He was a sergeant and served five years in both the UK and Afghanistan, (TV: The Caretaker) where he performed a number of humanitarian tasks, such as building wells, alongside traditional military work. (TV: Listen)
While on a mission in the Middle East, Danny accidentally shot and killed a young boy. (TV: Dark Water) He later referred to it as a "bad day" and the reason he left the army. (TV: Kill the Moon) REF: TARDIS Data Core: Danny Pink
FROM the CARETAKER Script:
COURTNEY: Miss Oswald, Katie Sharps says I pulled her hair in Biology.
CLARA: Courtney, you are big enough to look after yourself. Next class, jog on, I need to talk to Mister Pink.
COURTNEY: Ozzie loves the Squaddie.
CLARA: What was that?
ADRIAN: Of course, Danny Pink here is your man, Mister Smith. Five years' military experience, sergeant, here and Afghan, so electrics, boilers, if you need a hand, give him a shout.