Ogbonna headed past Jordan Pickford from a Jarrod Bowen corner with 16 minutes remaining as the Hammers secured three points against in-form Everton.
West Ham were the better team on Merseyside and deserved their win, though Alex Iwobi had earlier missed a golden chance to put Everton ahead in the first half.
Former Arsenal man Iwobi fluffed his lines and missed his kick when he was well-placed to score inside the area following a cross from Andros Townsend.
But it was another set-piece that did the trick for West Ham.
Since David Moyes returned to West Ham in January 2020, the Hammers have scored more goals from set-piece situations in the Premier League (29, excluding penalties) than any other side.
This win at Goodison Park moves West Ham up to sixth in the Premier League.