This paper is concerned with a practical inverse problem of simultaneously reconstructing the surface heat flux and the thickness of a solid structure from the associated ultrasonic measurements. In a thermoacoustic coupling model, the thermal boundary condition and the thickness of a solid structure are both unknown, while the measurements of the propagation time by ultrasonic sensors are given. We reformulate the inverse problem as a PDE-constrained optimization problem by constructing a proper objective functional. We then develop an alternating iteration scheme which combines the conjugate gradient method and the deepest decent method to solve the optimization problem. Rigorous convergence analysis is provided for the proposed numerical scheme. By using experimental real data from the lab, we conduct extensive numerical experiments to verify several promising features of the newly developed method.