I'm wondering if the floor under the carpet had been stained by a previous pet and the smell is in the wood. When I was building the addition onto my house last year, the contractor's new puppy stayed with him but kept peeing/pooping on the wood floor which I cleaned up. Even after cleaning and then eventually having carpet installed, my dogs could sense where the smell was. Maybe a professional cleaning of the carpet would help.
If he is straining to go onto the couch (if he is allowed) and this is when it happens, maybe have a set of steps nearby.