We study the problem of phase optimization for electric-vehicle (EV) charging. We formulate our problem as a non-convex mixed-integer programming problem whose objective is to minimize the charging loss. Despite the hardness of directly solving this non-convex problem, we solve a relaxation of the original problem by proposing the PXA algorithm where "P", "X", and "A" stand for three variable matrices in the formed phase optimization problems. We show that under certain conditions, the solution is given by the PXA precisely converges to the global optimum. In addition, using the idea of model predictive control (MPC), we design the PXA-MPC, which is an online implementation of the PXA. Compared to other empirical phase balancing strategies, the PXA algorithm significantly improves the charging performance by maximizing energy delivery, minimizing charging price, and assisting future energy planning. The efficacy of our algorithm is demonstrated using data collected from a real-world adaptive EV charging network (ACN).