Goals from Ryan Stevenson and John Sutton saw Hearts move into 10th place in the Clydesdale Bank Premier League - and six points behind sixth-placed Hibernian ahead of Sunday's Edinburgh derby at Easter Road.
Locke, whose first game after taking over from John McGlynn ended in a 2-1 defeat by Motherwell, said: "We showed everything required to get us out of the position we are in.
"There was great endeavour, work-rate, we were first to every ball and I felt we were a bit unlucky not to score one or two more goals. I was absolutely delighted to get a win and I dedicate that to John McGlynn and all the supporters that came."
The win came on a day of continuing financial uncertainty following the collapse of Vladimir Romanov's bank and his subsequent resignation from the board of UBIG, the club's majority shareholder.
The board earlier dismissed suggestions that Romanov had relinquished control of Hearts and then denied reports that staff had been told the club would be going into administration. But Locke insisted there had been no distraction.
"I have heard the rumours, I just think that's a bit of scaremongering," he said. "I don't know a lot about it, it's more the directors that deal with that side of things. I'm just here to concentrate on the football and I'm just delighted we got three points."
St Johnstone manager Steve Lomas admitted his side were "second best all over the park" as they failed to cope with Sutton and strike partner Michael Ngoo and missed the chance to move third.
Lomas said: "We have let ourselves down and let down the fans who have come down to support us.
"We were under no illusion what was going to happen. We saw the second half against Motherwell when they pretty much went direct every time up to big Ngoo and Sutton and they caused us problems. But it wasn't just them two, it was all over the park. When you don't win your individual battles, you come unstuck."