Thermal layers or 'thermoclines' are mostly a matter of luck and happenstance. Most US subs by 1944 had a device called a bathythermograph for detecting them, although the game generously gives you this detection ability through the whole war. If you should find a thermal while diving after an attack or even before one one consider yourself blessed.

Although no guarantee of a successful evasion from escorts they are a sub's natural ally.