The influence of a local change in surface temperature of a contoured nozzle corresponding to the Mach number M = 6 on the boundary layer stability and laminar-turbulent transition is numerically studied. The profiles of the laminar boundary layer are obtained by solving the Navier-Stokes equations with the use of the Ansys Fluid software system. N-factors of the growth rates of the Goertler vortices and also disturbances of the first and second Mack modes are calculated in the approximation of the linear stability theory. It is demonstrated that local heating ensures lower growth rates of the amplitudes of the Goertler vortices and the first Mack mode as compared to the base case; the more intense the heating, the more expressed this effect. The growth rate of the amplitude of the second-mode disturbances decreases during local heating of the nozzle to a temperature close to the stagnation temperature and increases at higher temperatures of local heating. It is found that local cooling leads to an increase in the growth rates of the amplitudes of the Goertler vortices and second Mack mode. The amplitude of the first Mack mode in the cooling region is smaller than that in the base case; however, further downstream, it is much greater than that in the base case. It is found that the surface of contoured nozzles should be heated in the region of the maximum growth rates of the amplitudes of the Goertler vortices; the higher the temperature, the more pronounced the expected effect. However, the maximum possible temperature is determined by the growth of the second Mack mode. The optimal option is to use the temperature of local heating of the surface at which the growth rate of the amplitude of the second mode is smaller than that of the Goertler vortices.