No, there is no necessary connection between the autopilot and an engine failing on any aircraft that I'm aware of -- which is far from all of them! If you're in an idle descent, one motor failing wouldn't really change the flight characteristics of the aircraft, so in that case there's no great need to get rid of the autopilot. Also, once you have everything trimmed up (i.e. rudder trim in to balance the asymmetric thrust), it's nice to put the autopilot on to let it keep the wings level & hold altitude for you while the pilots sort out everything that comes next -- checklists, ATC coordination, choosing where you'll land, etc.
What DOES come off almost immediately after engine failure, at least on the 737, is the Autothrottle. It will sense that the thrust and throttle position are mismatched, and rather than moving the good throttle around when you may not be ready to compensate with the rudder, it disengages. I'm not certain if that is universally true; the 777 computers are crazy smart, and they may actually leave the A/T engaged in that sort of a scenario (while the A/P flies the rudder for you).
The basic challenge that you mention, an autopilot that will hold altitude even when the thrust is insufficient to maintain airspeed, is a scenario that's not limited to an engine failure. The automation will have some set of rules as far as when to hold, when to go into reversion modes, and so forth. And if you get caught in the wrong spot, the automation can bite you. In the 737, for instance, if you're in altitude hold or glideslope capture, the autopilot will hold that no matter how badly the speed decays. (Stall while on glide path, or follow the speed cursor into the dirt short of the runway... damned if you do, damned if you don't!) On the other hand, if you're in a vertical speed mode or a VNAV climb or descent, there are speed reversions that will change your flightpath rather than accepting a speed above or below safe limits. If everything has been set up correctly and the Autothrottle is engaged (or the pilot is setting the power appropriately), then everything works really well. But if enough things go wrong and you aren't paying attention... well, that's when bad things can happen.