We study the torque acting on a planet embedded in an optically thick accretion disc, using global two-dimensional hydrodynamic simulations. The temperature of an optically thick accretion disc is determined by the energy balance between the viscous heating and the radiative cooling. The radiative cooling rate depends on the opacity of the disc. The opacity is expressed as a function of the temperature. We find that the disc is divided into three regions that have different temperature distributions. The slope of the entropy distribution becomes steep in the inner region of the disc with high temperature and the outer region of the disc with low temperature, while it becomes shallow in the middle region with intermediate temperature. Planets in the inner and outer regions move outwards owing to the large positive corotation torque exerted on the planet by an adiabatic disc, and on the other hand, a planet in the middle region moves inwards towards the central star. Planets are expected to accumulate at the boundary between the inner and middle regions of the adiabatic disc. The positive corotation torque decreases with an increase in the viscosity of the disc. We find that the positive corotation torque acting on the planet in the inner region becomes too small to cancel the negative Lindblad torque when we include the large viscosity, which destroys the enhancement of the density in the horseshoe orbit of the planet. This leads to the inward migration of the planet in the inner region of the disc. A planet with 5 Earth masses in the inner region can move outwards in a disc with surface density of 100 g cm−2 at 1 au when the accretion rate of a disc is smaller than 2 × 10−8 M⊙ yr−1.