This happened to one of my cory's. He got stuck in a hole in the wood that had been covered up by a moss ball that had floated on top of it.
We managed to prise him out with the thin end of a chopstick and he popped out like a little cork. He was a bit shocked after his ordeal but he is fine now.