Harvey Barnes opened the scoring after 24 minutes, tapping in from Ricardo Pereira's pass for his first home Premier League goal.
After losing Jamie Vardy to an injury, Leicester doubled their lead in first-half stoppage time through Pereira.
Barnes turned provider this time, picking out the right-back, who struck low past Darren Randolph.
Mark Noble made it 2-1 from the penalty spot on 50 minutes after Leicester substitute Wilfred Ndidi had fouled Sebastien Haller.
Perez restored Leicester's two-goal lead in the 81st minute with a penalty after Angelo Ogbonna fouled Kelechi Iheanacho before the Spaniard made it 4-1 on 88 minutes.
Leicester stay third with 48 points, three behind Manchester City. West Ham remain 17th on 23 points.
Leicester: 1 Feb v Chelsea (H)
West Ham: 29 Jan v Liverpool (H)