In the past, the optimization of engineering specifications primarily included the influence of quality loss terms on product quality; however, in actual production practice, compensation quantity inevitably affects the optimization quality of engineering specifications. In this paper, the quadratic exponential quality loss and gain function was first supplemented, and the quadratic exponential quality loss and gain function was constructed under the larger-the-better characteristic and the smaller-the-better characteristic; in order to accurately represent the change in compensation amount in the process of quality control, the optimization method of engineering specification under the calculation of quality loss and compensation was given in combination with the hyperbolic tangent function. Finally, with the support of the dam construction quality acceptance assessment, the engineering specification optimization model was tested. The optimal coefficient was obtained as 0.162, and the specification range was reduced from 0.744 to 0.648, achieving the optimization goal.