Cell balancing control for Li-ion battery pack plays an important role in battery management system. It contributes to maintaining the maximum usable capacity, extending the cycle life of cells, and preventing overheating and thermal runaway during operation. This paper presents an optimal control of active cell balancing for serially connected battery pack that maintain the cell's current and temperature in a suitable range during the equalizing process. Using the cell-to-cell balancing circuit based on CuK converter for two adjacent cells, the state of charge (SoC) and temperature dynamic of cells in the pack is modelled. Then, the optimal control problem for active cell balancing is established with constraints on cells' current and temperature. The solution of this nonlinear optimal problem solved by using sequential quadratic programming(SQP) is the optimal duties fed to the cell balancing circuits. The experimental test applied to battery pack of 07 Samsung cells connected in series, the reliable and efficient results show that cell balancing process takes place shortly and adaptively depending on the discharge/charge current of pack, the desired temperature increasing limit, and technical constraints of balancing circuits.