The 19-year-old midfielder's previous deal expired at the end of the season but he will be part of new head coach Robbie Neilson's plans for the upcoming Scottish Championship campaign.
The Scotland Under-19 cap made his debut against Inverness last August and made 26 appearances in total, scoring two goals.
The Gorgie club's director of football, Craig Levein, told Hearts News: "We'll make a lot of signings over the summer and I'm expecting seven or eight players to come in but I doubt if any of those will be as significant as Sam re-signing.
"He showed great maturity last season, for someone so young. Once he got his chance in the first team, what impressed me almost as much as his ability was his work-rate and his knowledge of the position that he played in.
"He's got a willingness to help his team-mates and that is very valuable. From his debut he really lit the place up.
"He's very much one of our, and Scotland's, brightest young talents. It confirms to the Hearts support and everybody out there that we're serious about developing young players.
"Sam committing for another three years is excellent news for everybody."
Meanwhile, striker Soufian El Hassnaoui is set to become Neilson's latest signing after agreeing a three-year deal with Hearts.
The 24-year-old Dutch-born Moroccan joins, subject to international clearance, from Sparta Rotterdam.
El Hassnaoui represented Morocco in the Olympics and Neilson is confident he will be a success.
He told the club's official website: "Soufian's a player we see talent in. We can see his desire.
"We spoke to him to get an idea of what he's like and we spoke to some people in Holland who knew him and played against him, and all the reports were good.
"The first conversation we had, we told him he's coming in here to develop and but also to help us develop the young boys.
"He was brought up in the Dutch system so he's got a very good tactical knowledge of the game and he understands the game. He can definitely help our younger players to progress as well.
"He can play up front on his own, he can play with a partner or he can play behind the striker.
"He's very versatile and he's got a lot of talent. He's a good age as well.
"He's still got ambition to move on to a higher level, which is what we need; guys that are going to come in and develop themselves, develop the youngsters and develop the club."