Locke took charge on a caretaker basis following the departure of John McGlynn and has seen the Jambos claim four points from his three SPL games at the helm.
Hearts had been tipped to appoint Peter Houston next week after holding talks with the former Dundee United manager, but opted to stick with Locke ahead of Sunday's Scottish Communities League Cup final against St Mirren.
"It has certainly come as a bit of a surprise," said Locke.
"I've been happy with the way things have gone in the last couple of weeks and hopefully we can finish the week on an ultimate high by bringing a cup back to Tynecastle.
"John McGlynn has played a huge part in getting us to the final and for me to lead them out is a wee bit embarrassing but I'm delighted to get my future sorted out.
"I'm really looking forward to the cup final and the only thing on my mind now is to try to get the team to win on Sunday.
"I'm really delighted. The opportunity has come a wee bit earlier than expected but I certainly aim to take it with both hands."