After Jamie Hamill had scored for Hearts to level the tie following a Liam Fox opener, Raith had Dougie Hill sent off in the 74th minute, but still managed to force penalties
However, Brad McKay then converted the decisive spot-kick to give Hearts a 5-4 shoot-out win in the second-round encounter.
And Locke said: "It was certainly not what we wanted, with it going to extra-time.
"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.
"We're delighted to be through, the boys' character was fantastic."
Sending-off angers Murray
Hill was sent off for an apparent head-butt on Hamill but Raith boss Grant Murray was unhappy about the decision.
"It was not a sending off, I've seen the video evidence just now," he said.
"It changes the game as well but we have to take it on the chin and move on.
"I've not spoken to the ref, I've just watched the video. Dougie is saying he never touched him. He is saying they walked up to each other and the Hearts player went down.
"It's very disappointing, you see it in a lot of games with players going together. If there is no contact there, it's very disappointing from our point of view."