This paper presents a study on enhancing the efficiency of underwater gravity matching navigation path planning in a three-dimensional environment. Firstly, to address the challenges of the computational complexity and prolonged calculation times associated with the existing three-dimensional path planning algorithms, a novel Three-Dimensional Along-Path Obstacle Profiling (TAOP) algorithm is introduced. The principles of the TAOP algorithm are as follows: (1) unfolding obstacles along the path using the path obtained from two-dimensional planning as an axis, interpolating water depth values based on downloaded terrain data, and subjecting obstacles to dilation treatment to construct a dilated obstacle profile for path segments; (2) conducting height direction course planning and a secondary optimization of the path based on the profile contours of the dilated obstacles; and (3) integrating height planning with the path points from two-dimensional planar planning to obtain a complete path containing all turning points in the three-dimensional space. Secondly, gravity anomaly data are utilized to delineate gravity suitability areas, and a three-dimensional planning environment that is suitable for underwater gravity matching navigation is established by integrating seafloor terrain data. Under identical planning environments and parameter conditions, the performance of the TAOP algorithm is compared to that of the RRT* algorithm, Q-RRT* algorithm, and Depth Sorting Fast Search (DSFS) algorithm. The results show that, compared to the RRT* algorithm, Q-RRT* algorithm, and DSFS algorithm, the TAOP algorithm achieves efficiency improvements of 15.6 times, 5.98 times, and 4.04 times, respectively.