In March 1942, Afanasenko was drafted into the Red Army. He was assigned to the 197th Rifle Division from 7 August. He fought in the Battle of Stalingrad, after which the division became the 59th Guards Rifle Division. Afanasenko later fought in Operation Gallop, the Donbass Strategic Offensive, the Zaporizhia Offensive, the Nikopol–Krivoi Rog Offensive, the Odessa Offensive, the Second Jassy–Kishinev Offensive, the Bucharest-Arad Offensive and the Battle of Debrecen. In 1944, Afanasenko joined the Communist Party of the Soviet Union. On 10 August, he was awarded the Order of the Red Star. On 28 October 1944, Afanasenko was awarded the Medal "For Courage". By December 1944, he was an Efreitor in the 66th Guards Separate Combat Engineer Battalion of the same division.