The Jambos finally came out on top 4-2 on penalties in the third-round tie, having been pegged back three times over the course of 90 minutes and extra time.
The Edinburgh side had headed into the clash at Tynecastle on the back of three straight defeats and Locke insists the win, regardless of the nature of it, will have a positive effect on his players.
He said: "It's huge, it's great for the confidence. At the end of the day, in the cup competitions, it's just all about being in the next round.
"Whether it's in 90 minutes, extra time or penalties, we are through and that's the most important thing. It will give everyone a boost.
"The players are certainly a lot happier than what they were after the game on Saturday. We played well and there were a lot of positives to take."
Hearts skipper Danny Wilson must have thought he had grabbed the winner just two minutes later but Chris Higgins struck as Queens hit back for a third time, with penalties looming.
Dale Carrick eventually netted the winning goal in the shoot-out to ensure Hearts' name would be in the hat for the quarter-final draw.
Locke added: "It was a very difficult game and it always was going to be a hard game.
"I've seen Queen of the South a few times and had them watched a number of times.
"They've got a lot of boys that have been around for a while and you can see they've got a lot of good experienced players.
"I thought they were a credit to themselves. Jim McIntyre's got them playing really well.
"You score three goals at home and you think it should be comfortable.
"We obviously need to do a little bit better defensively but in the main we are just delighted to be through."
Queens boss McIntyre had no complaints about the effort of his own players.
He said: "First and foremost there's a lot of pride in the players. We went behind three times and kept at it.
"We just needed to be more ruthless because we had some really good opportunities.
"I thought we were excellent but all credit to Hearts, they were ruthless with their chances.
"When it comes to penalties it's a lottery. It's about holding your nerve and you need a bit of lady luck. It's always been the same."