A clearance in the six-yard box rebounded off Pienaar and into the goal in the 73rd minute, shortly after West Ham's Carlton Cole was sent off for a high-footed challenge on defender Leighton Baines.
Cole had given the home side an early lead when he scored from close range in the 14th. Victor Anichebe equalized for Everton with a headed goal in the 63rd.
Everton had midfielder Darron Gibson sent off in the final minute but the visitors hung on for all three points.
West Ham stays 11th in the standings with 23 points while Everton moves up one place to fourth with 30 points.