England made a slow start as Burns was run out early in the day.
Herath dismissed Root for the second time in the game as England slipped to 74 for 3.
Stokes and Jennings scored 107 for the fourth wicket to help England take lead past 300.
Stokes was bowled after a 93-ball 62.
Jennings struck an unbeaten 146 to help England set Sri Lanka a target of 462.
Herath picked up three wickets in his final Tests to end with 433 scalps. Sri Lanka openers ended the day at 15 for no loss as England continued to boss the game.