Cole brought the Reds level at 2-2 after being introduced as a substitute in the first half, before emergency striker Jonjo Shelvey helped force a winner via James Collins at Upton Park.
"It was very important for us. West Ham were three points above us, and we needed to keep doing the right things we've been doing," said Cole, a former Hammer.
"It was a great win - it's always nice to come back to your old club. I've scored a few against West Ham but never celebrated - the most important thing was getting the win.
"It's a great group of young players here and we've got the right manager for them - they have done really well."