An immersed boundary method is proposed for RANS (Reynolds-Averaged Navier-Stokes) simulation of compressible turbulent flows. In the method reference points are no longer utilized in interpolation for solution reconstruction and flow variables at the mesh nodes in immediate vicinity of solid wall are determined with inverse distance weighting interpolation of those at surrounding computed nodes. To reduce the requirement of high near-wall mesh resolution in simulation of high-Reynolds-number turbulent flows, an explicit wall function is employed to transform the no-slip boundary condition into the no-penetration condition and a prescribed wall shear stress. The wall function does not need to be solved iteratively which improves computational efficiency. Numerical experiment for subsonic and transonic flows around RAE2822 airfoil verifies reliability of the method.