The Hammers put out a near full strength team, and took the lead through England Under-21 striker Jermaine Defoe midway through the first half.
However, Orient's Gary Fletcher equalised on the stroke of half time from a corner.
Kevin Nugent put the O's ahead in the 86th minute with a header, and Jamal Campbell-Wright sealed the 3-1 victory in injury time.
4790 were at Brisbane Road to see the giant-killing feat.