In this paper, an iterative method is proposed for solving the matrix inverse problem $AX=B$ for Hermitian-generalized Hamiltonian matrices with a submatrix constraint. By this iterative method, for any initial matrix $A_0$, a solution $A^*$ can be obtained in finite iteration steps in the absence of roundoff errors, and the solution with least norm can be obtained by choosing a special kind of initial matrix. Furthermore, in the solution set of the above problem, the unique optimal approximation solution to a given matrix can also be obtained. A numerical example is presented to show the efficiency of the proposed algorithm.