After scoring the winner in the third round against Fleetwood Town on New Year day, Appiah missed Wimbledon's following three games through injury but was passed fit for West Ham clash.
Wimbledon may be bottom of League One, and 58 places adrift of West Ham, but that did not stop them being 3-0 up early in the second half, with Scott Wagstaff scoring twice after Kwesi Appiah's opener.
Hammers substitutes Lucas Perez and Felipe Anderson scored to make it 3-2, before Wimbledon's Toby Sibbick, not even born when the club won the 1988 FA Cup final against Liverpool, headed in the winner two minutes from time.
AFC Wimbledon took a deserved lead in the 34th minute through Appiah's deflected shot from the edge of the box.
They were 2-0 up before the break. Wagstaff ran all the way to the edge of the box unopposed after dispossessing Pedro Obiang on halfway before calmly slotting the past Hammers keeper Adrian.
Then just seconds into the second half, Wagstaff made it 3-0 when, following an Apppiah cross, he scored from 12 yards.
Perez pulled one back in the 57th minute and before Anderson's free-kick raised hope of a Hammers equaliser
But 19-year-old substitute Sibbick then headed in an excellent cross from Anthony Wordsworth to put the result beyond doubt.