Acoustic coatings with periodically arranged internal cavities have been widely applied to underwater vessels to reduce the underwater sound scattering. In this study, the simulation results from the finite element method (FEM) have been compared with the theoretical solutions based on the transfer matrix theory (TMT), and the reliability of the FEM has been verified. The Nelder-Mead algorithm has been employed to optimize the structure of the coatings and the material parameters with the sound absorption coefficient as the primary optimization objective. A function that characterizes the shape of a two-dimensional axisymmetric cavity has been proposed, and the peak value of the absorption coefficient can be successfully moved to the target frequency by changing the weighting strategy. The results show that the sound absorption coefficient of the optimized coating increases and the peak shape widens in the middle and low frequency band. The optimized axisymmetric cavity significantly improves the sound absorption performance of the anechoic coatings. The optimization algorithm of the cavity structure and material parameters proposed in this study provide an effective pathway for the optimal design of the anechoic coatings.