The switching of multiple working modes between power sources or axles through an economic torque distribution strategy can cause longitudinal jerk problems in electric vehicles equipped with multiple power sources and multi-axle drive systems. To address this issue, an online real-time dynamic torque distribution strategy was proposed. This strategy can suppress the longitudinal jerks in real-time and minimize the total power loss of the vehicle. In this study, a vehicle dynamics model, which considers a nonlinear system, is developed to reflect the transient process of the torque dynamic response of a vehicle transmission system. The main factors influencing the longitudinal jerk of the vehicle were analyzed. To minimize the total power loss of the vehicle, a dynamic power loss model of the electric drive system is established, and the model accuracy is experimentally verified. Through optimal control theory, this study proposes an online real-time dynamic torque distribution strategy that achieves the lowest total power loss of a vehicle while suppressing the longitudinal jerk. Under WLTC conditions, the longitudinal jerk is reduced by 79.46 % during mode switching, resulting in improved driving comfort, and the effectiveness of this strategy is verified via the experimental bench of the dual-motor four-wheel-drive electric drive system.