This paper presents a robust and fast Model Predictive Control (MPC) method for maintaining balance and performing trajectory planning in dynamic obstacle scenarios during humanoid robot locomotion. The balance conditions and motion equations of the robot are expressed within a single objective function, and constrained optimization is solved using Sequential Quadratic Programming (SQP). This approach facilitates both maintaining balance and performing obstacle avoidance maneuvers in dynamically changing environments. The method has been performance-tested using Augmented Lagrangian (ALM) and Trust Region Constrained (TRC) Methods, and it has been observed to provide faster responses on hardware with limited computational power. The study was simulated in the Gazebo simulation environment using the Robotis-OP3 humanoid robot, demonstrating that the proposed optimization-based approach provides fast and stable control results.