The winger headed in at the back post from Ross Barkley's flick-on from a corner to give the Premier League strugglers the lead.
He then ran to the dugout and held a Lockyer shirt in the air a week after he suffered a cardiac arrest against Bournemouth.
Luton's captain collapsed on the pitch in the second-half against the Cherries, with the match eventually being abandoned.
Lockyer has now been discharged from hospital after he had an Implantable Cardioverter Defibrillator (ICD) device fitted.
Fans of the footballing world have shown huge support for him ever since, with Luton boss Rob Edwards 'so proud' of the medics and everyone who helped.
READ MORE ON TOM LOCKYER
Shaken Edwards opens up on Lockyer incident in first interview since Luton star collapsed
Luton captain Tom Lockyer discharged from hospital following cardiac arrest
Fans at Kenilworth Road stood and applauded Lockyer in the fourth minute of the match, with Townsend's goal coming a little later.
It's his first for the club since signing on a short-term contract in the summer, coming in his ninth appearance.