Herath bamboozled Australia's batsmen from the outset, luring Steve Smith out of his crease in the first over, but wicketkeeper Dinesh Chandimal failed to complete the stumping.
However, in his next over, the skipper tried to cut a skidding delivery and was bowled for an awkward five from 10 balls.
That blow came after Usman Khawaja was bowled the previous over by Dilruwan Perera, also beaten on the inside edge of the bat.
Adam Voges and Mitch Marsh then added 21 not-always-convincing runs before Herath's stunning hat-trick.
He had Voges caught at cover, Peter Nevill plumb lbw and Starc trapped in front off successive balls.
There was drama, with the lbw appeal against Starc turned down but given when Sri Lanka captain Angelo Mathews reviewed the decision via DRS.
Herath's hat-trick was the 42nd in Test cricket and just the second by a Sri Lankan player after Nuwan Zoysa's in 1999 against Zimbabwe.
After snaring match figures of 9-107 in Kandy, the 38-year-old banked 4-35 at a ground where he's enjoyed enormous success.
Marsh was the last batsman dismissed for 27, his three big sixes down the ground off Herath towards the city's famous fort helping Australia limp into three figures.
Off-spinner Perera, who wasn't much of a threat in the first Test, was tough to handle and finished with 4-25.
His dismissal of a rampant David Warner on the last ball of day one for 42 was critical. Australia's other tormentor from Kandy, left-arm wrist spinner Lakshan Sandakan, needed only two balls to wrap up the innings as the tourists conceded a 175-run deficit.
AUSTRALIA'S LOWEST TOTALS AGAINST SRI LANKA
* 106 in Galle, 2016
* 120 in Kandy, 2004
* 140 in Kandy, 1999
* 161 in Pallekele (Kandy), 2016
* 188 in Kandy, 1999
* 201 in Darwin, 2004
* 203 in Pallekele, 2016
- AAP