I do not think it can back out. the shape of a pleco's head is kindof like and arrow. But when it goes into a snall hole the stdes of the head will be compressed against the head some and it fits. It cannot make those parts compress voluntarily so it can pull its hed out. Unlees it can swimm inside, turn around and swim out head first it may be stuck.
That said, I work with breeding a number if Hypancustrus. I sometime need to get a male out of a small cave. When they do not want to come out they sptead their pectoral fins and will not be removed no matter what, even if you take the cave out of the water. So there have been a number of occasions when I have had to smash a terracotta cave to get the fish out. I have never harned a fish doing this and have had to really trash a few caves , I break the gave with it on a hard surface using a hammer. The trick is to stike the ccave, or in your case the chest, as far from where the fish is. Do not tru to smash the cave to bits, strike a short swift blow to near one of the far corners. of you cab break of a part you should be habe to use a pliers to hold th chest and smack another piece off. Never hit the chest close to the fish. i think if you can open a hole big enough for it to swim out of all you have to di then is put it back in the water.
The fish will not live very long staying stuck. I may be wrong, but I do not believe the fish would be swimmng around stuck as you describe if it could get out. If i am right you will have to try what I suggested. So, if any of the above advice doesn't solve the problem........