Ayew had been watching from the sidelines alongside Anglo-Nigerian striker Tammy Abraham as Paul Clement opted to hand retuning attacker Wilfried Bony the nod to lead the frontline.
Alifie Mawson had put his side in front shortly after the break when he turned home Sanches' low corner before Ayew made the most of a late counter-attack to settle the tie.
Ayew curled a low effort into the bottom corner, past Anssi Jaakkola to secure the win after being played through on a break.
The strike was the Ghanaian’s third of the campaign having netted once in the Premier League and also in the League Cup before.
Bony’s return to the Liberty Stadium side will mean both Ayew and Abraham will have to work extra hard to continue leading the Swans’ attack ahead of the Ivorian.
Swansea have now won 14 of their last 17 League Cup contests against lower league opponents
The 26-year-old will be hoping to return to the starting lineup and also get on the scoresheet when Swansea host Watford in the Premier League on Saturday.