The Italian champions had trailed the Russians with 13 minutes to go in the Allianz Stadium after Aleksei Miranchuk had put the visitors ahead after half an hour.
But Dybala pulled the hosts level on 77 minutes and added a second two minutes later to keep Juventus on course in Group D with seven points after three games.
Sarri's side had drawn with Atletico Madrid and beaten Bayer Leverkusen 3-0 in the last two games.
Atletico also have seven points, after beating Leverkusen 1-0 in Spain on Tuesday, with Lokomotiv third with three points.
"It became a difficult match when we conceded this goal," said former Chelsea boss Sarri.
"But we did well not to lose our heads. We knew we could get back into the match.
"We had 25 shots on goal, we established a record for possession, so we played well.
"It wasn't an exceptional day, we play every three days, so a less brilliant day."
Cristiano Ronaldo missed the chance for another record of scoring against a 34th different Champions League club.
The Portuguese star drew a blank in Turin, firing over from a Juan Cuadrado cross early as, despite dominating possession, Juventus struggled to break down the Russians.
Lokomotiv broke through with their first clear chance.
Miranchuk shrugged off Leonardo Bonucci and the Juventus defence to find on-loan Inter Milan midfielder Joao Mario whose effort was cleared by Polish keeper Wojciech Szczesny into the path of the Russian forward who finished.
"It was a tough game," said Miranchuk.
"We got tired closer to the end and lost focus. Juve are a dangerous team and punished us for that."
Dybala looked as if he had scored the equaliser before the break but play had stopped following Ronaldo's tackle on Lokomotiv goalkeeper Guilherme.
Dybala fired over just after the break with fellow Argentine forward Gonzalo Higuain coming on in place of Sami Khedira.
Szczesny cleared a Joao Mario effort after an hour while at the other end Higuain missed two quick-fire chances before Dybala finally rifled in the equaliser.
Alex Sandro was denied two minutes later but Dybala was on hand to follow up to keep Juventus unbeaten in all competitions this season.
"I'm very happy, I really needed two goals like this," said Dybala.
"It was a difficult game but tonight you could really see the level of experience of our team. We always remained calm until we finally scored."
The Argentine was substituted after his double to an ovation from the home crowd.
It had been a difficult start to the season for the 25-year-old who had looked set for a move away from Turin to either Tottenham or Manchester United after Higuain's return from Chelsea.
"Now we won and you all say that we can play together. But if we were losing, the opinions would have been completely different," he added of the partnership with Ronaldo and Higuain.
"It was a painful victory, then a great goal from Dybala made the difference," said Szczesny.
Lokomotiv coach Yuri Semin said "it was a logical" defeat.
"We didn't have enough strength in the end. I didn't make substitutions in the hope that we would survive the final push from Juve, but we didn't."