The Jambos conceded to Liam Fox five minutes into the second half before Jamie Hamill's 61st minute penalty levelled it at Stark's Park which eventually saw the game into extra-time and subsequently to a penalty shootout.
Hearts managed to edge their Championship opponents 5-4 in the shootout and Locke was content with progressing to the third round despite the scare.
"It was certainly not what we wanted, with it going to extra-time," said Locke.
"We did not do too well in the first half but the second half was a lot better. They got everyone behind the ball when they went down to 10 men (after Dougie Hill's sending off in the 74th minute).
"We're delighted to be through, the boys' character was fantastic."
Need a VPN? Or seeking to switch? Then support Tribal Football by clicking here to sign up with our official partners NordVPN. Not only will you receive the best VPN experience, but also great discounts by signing up via Tribal Football. Thanks for your support!