In this paper, a bilateral free boundaries problem is considered. This kind of inverse problems appears in the theory of semiconductors and multi‐phase problems. Using a shape functional and some regularization terms, an optimal control problem is formulated. In addition, we prove its solution existence. The first optimality conditions and the shape gradient are computed. With the finite element method, we write the discrete version of the optimal control problem. To design our proposed scheme, we based on the conjugate gradient, where we use the genetic algorithm to find the best initial guess for the gradient method. At each mesh regeneration, we perform a mesh refinement in order to avoid any domain singularities. Some numerical examples are shown to demonstrate the validity of the theoretical results and to prove the robustness and efficiency of the proposed scheme, especially to identify free boundaries with jump points.