The Championship leaders netted twice in the opening 31 minutes through Gary Oliver and Kevin McHattie, and although the home team hit back through Kieran Millar before the break Hearts progressed to the next round.
Hearts took the lead on six minutes when David Smith surged down the right and crossed for the unmarked Oliver to fire past Greg Fleming into the top of the net.
The Jambos doubled their advantage when Jamie Walker slipped a pass to McHattie and he fired a shot into the bottom corner.
But the Warriors responded seven minutes later after when Martin Grehan chested down for Miller to finish from inside the penalty area.
After the break Hearts came close to adding a third when Osman Sow connected with a corner but his header came off the crossbar.