The ultra-short baseline positioning system (USBL) has the advantages of flexible application and easy installation, and it plays an extremely important role in the underwater positioning and communication. The error of the USBL in underwater positioning is mainly caused by a ranging error due to ray tracing, a phase difference error of the USBL, and acoustic noise in the underwater communication. Most of these errors are related to the changes in the sound speed during its propagation through the ocean. Therefore, when using the USBL for underwater detection, it is necessary to correct the sound speed profile in the detection area and optimize the ray tracing. Taking into account the actual conditions, this paper aims at correcting the model of underwater sound speed propagation and improving the tracking method of sound lines when the marine environment in the shallow sea area changes. This paper proposes a combined ray tracing method that can adaptively determine whether to use the constant sound speed ray tracing method or the equal gradient ray tracing method. The theoretical analysis and simulation results show that the proposed method can effectively reduce the error of slant distance in USBL compared with the traditional acoustic tracking method and the constant sound speed ray tracing method. The proposed sound ray correction algorithm solves the contradiction between the number of iterations and the reduction of positioning error and has engineering application value.