This subject turns out to be fairly complicated. A general guideline is to have a minimum insertion into the flowing stream of 2″ (50 mm) for liquid service and 3″ (75 mm) for vapor service. Other guidance is to have the insertion at least 1/3 of the pipe diameter. The caveat is a wake frequency calculation should be done before finalizing the insertion length. High velocities can result in causing the thermowell to vibrate at its natural frequency and then fail due to fatigue. This calculation is covered in ASME PTC 19.3
If the thermowell is not inserted at least 2″ (50 mm) into the flowing stream, the indicated temperature will be lower than actual causing the heater to be over-fired. If the insertion length is too long or the velocity of the stream increases from the design values, the likelihood of the thermowell failing catastrophically increases.
I am aware of a few installations where the insertion length was too short due to a concern over the wake frequency and failure of the thermowell over time that resulted in the heater outlet temperature reading as much as 10 F (6 C) too low. These problems were resolved by increasing the insertion length to at least 2″ (50 mm) into the flowing fluid.