I always imagined this phrase conjured some violent altercation – not so!
The expression comes from the world of military aviation. In many planes, control sticks are topped with a ball-shaped grip. One such control is the throttle—to get maximum power you push it all the way forward, to the front of the cockpit, or firewall (so-called because it prevents an engine fire from reaching the rest of the plane). Another control is the joystick—pushing it forward sends a plane into a dive. So, literally pushing the balls to the (fire)wall would put a plane into a maximum-speed dive, and figuratively going balls to the wall is doing something all-out, with maximum effort.
Wordorigins says the earliest written citation is from 1967, appearing in Frank Harvey’s Air War—Vietnam: “You know what happened on that first Doomsday Mission (as the boys call a big balls-to-the-wall raid) against Hanoi oil,” though Slate says Korean War veterans claim they used the phrase earlier.