In this paper, we propose an approach for solving an energy-optimal goal assignment problem to generate the desired formation in multi-agent systems. Each agent solves a decentralized optimization problem with only local information about its neighboring agents and the goals. The optimization problem consists of two sub-problems. The first problem seeks to minimize the energy for each agent to reach certain goals, while the second problem entreats an optimal combination of goal and agent pairs that minimizes the energy cost. By assuming the goal trajectories are given in a polynomial form, we prove the solution to the formulated problem exists globally. Finally, the effectiveness of the proposed approach is validated through the simulation.