Substitute Walker scored in the 79th minute and King’s goal six minutes later secured a seventh-consecutive league victory for Hearts.
Kevin McHattie, making his first appearance since November 22 following a knee injury, fired Hearts into a 27th-minute lead at Stark’s Park.
But Craig Barr’s header from a Ryan Conroy corner for Raith made it 1-1 at half-time.
Raith’s Christian Nade was sent off – the striker was given a straight red card – for a foul on defender McHattie in the 64th minute when 1-1.
McHattie tapped in James Keatings’ deflected effort from close range for the opener before Barr’s 43rd-minute equaliser for Raith, who remain sixth after a seventh home Championship defeat of the season.
Hearts, who secured a 12th away league victory so far, regained the lead after Nade’s dismissal when Walker cut in from the left and slammed a low shot into the far corner.
And, with five minutes of normal time remaining, Walker set up King for a third goal for Robbie Neilson’s runaway leaders.