Aiming to more accurately control the wheel speed of an electric vehicle (EV) driven by four in-wheel motors, a developed whale optimization algorithm-proportional–integral–derivative (KW-WOA-PID) control algorithm is proposed herein. In this study, mathematical and simulation models are built for EVs by analyzing the mechanical structures of EVs driven by four in-wheel motors. Simulations are conducted, and the driving and control requirements for the in-wheel motors are obtained. Then, mathematical and simulation models are built for a specific in-wheel motor. The whale optimization algorithm (WOA) is optimized by kent mapping and the adaptive weight coefficient to improve the ability of the algorithm to jump out of the local optimum and the convergence speed and convergence accuracy of WOA. Then the further simulations are conducted. The simulation results display that the maximum overshoot and adjustment time of the motor under KW-WOA-PID control are significantly optimized. Then, a speed-control bench test system is built for the in-wheel motor, and real-life experiments were conducted. The experimental results verify that KW-WOA-PID has higher control accuracy and a better response performance; accordingly, the developed control algorithm can meet driving requirements. The handling stability of EVs is effectively improved by controlling the motor speed.