The Hammers have now racked up wins against Cork City, Boreham Wood and Bournemouth in the last 10 days.
The shot-stopper's poor kick hit Cole on the back and then spun into the bottom left corner of the net.
Cole was involved again as the Premier League outfit doubled their lead on 50 minutes.
The England international's corner found James Collins, who guided a precise header just inside the far corner.
Despite the visitors' dominance, Jabo Ibehre managed to head home a consolation goal for Colchester in second-half stoppage time.