Harvey Barnes tapped in Ricardo Pereira's cross to give Leicester a 24th-minute lead, but the Foxes suffered a potentially major blow shortly before half-time when Premier League top scorer Vardy went off with what looked like a hamstring injury.
There was time for a second Leicester goal prior to the break, with Barnes darting in from the left and teeing up Pereira, returning the earlier favour and allowing his team-mate to thunder a shot beyond Darren Randolph.
Mark Noble slotted in a 50th-minute penalty to revive West Ham's hopes after Wilfred Ndidi fouled Sebastien Haller.
However, when Angelo Ogbonna caught Kelechi Iheanacho Leicester were awarded a spot-kick of their own and Perez fired the ball high and emphatically into the net to make the home win a certainty.
Perez rifled in a clinical late fourth for Brendan Rodgers' third-placed hosts, who coped admirably without Vardy but will nevertheless hope his absence is brief.