Herath and spin partner Dilruwan Perera claimed four wickets apiece as Australia, resuming on 54-2, collapsed for 106 runs to give the hosts a 175-run first innings lead at the Galle International Stadium.
Mitchell Starc (2-17) and Josh Hazelwood (1-2) reduced Sri Lanka to 31 for three at lunch but the hosts already lead by 206 runs with seven wickets in hand.
Kusal Perera was batting on 15 at the break with skipper Angelo Mathews (zero) at the other end as Sri Lanka pressed for a series-clinching victory.
Herath had tormented Australia in the first test at Pallekele too, exposing the visitors’ vulnerability against spin bowling and claiming nine wickets in Sri Lanka’s 106-run victory.
The 38-year-old returned to haunt them again on the second morning, bowling captain Steve Smith for five runs with the first delivery of his third over.
He then ripped the heart out of Australia’s batting in his eventful seventh over, inducing Adam Voges into a drive with his fourth delivery and Dimuth Karunaratne took a brilliant catch at extra cover to complete the dismissal.
His next delivery was an arm ball that trapped Peter Nevill plumb in front and Herath struck Starc’s pad with his next delivery but the leg-before appeal was turned down.
After a brief chat with the spinner, home captain Angelo Mathews decided to review the decision and Herath, who claimed 4-35, was mobbed by team mates as the not-out decision was overturned.