The Glovers struck twice in three minutes with goals from midfielder Danny Schofield and striker Paul Warne.
Schofield's shot from the edge of the penalty area took a deflection before hitting the net via the far post.
Warne then grabbed Yeovil's second when he met a low cross from Aidan Downes before beating goalkeeper Craig Samson at the near post.
Hereford failed to get a shot on target in the first half but they stepped up a gear after the interval with Simon Johnson and Sam Oji both seeing efforts turned away for corners. Striker Moses Ashikodi also had a penalty appeal turned down when he was upended by goalkeeper Asmir Begovic as they both chased for the ball.
But with nine minutes to go Bradley Hudson-Odoi latched rifled a loose ball past Begovic. And in a dramatic finale Steve Guinan was denied by the woodwork, heading a cross from Jack Macleod onto a post.