The Mexican forward is only in the side due to a Real injury crisis but followed up the goal that knocked Atletico Madrid out of the Champions League last Wednesday with a strike in both halves.
Toni Kroos slotted in the equaliser after 16 minutes following the opener by Celta winger Nolito and then Hernandez finished clinically after 24 minutes.
In a pulsating game, Celta's Santi Mina then knocked the ball home after his initial effort hit a post.
Cristiano Ronaldo also struck the woodwork before a James Rodriguez drive from the edge of the area flicked off Andreu Fontas and past keeper Sergio Alvarez before halftime.
Hernandez expertly brought down a Sergio Ramos pass and beat Alvarez after 68 minutes to seal a win that sees Real move two points behind Barca, who beat Espanyol 2-0 on Saturday.