Where did this saying come from then? Believe it or not, it's from the aviation industry. Planes have a mixture of switches and levers that the pilot must understand and use to fly a plane. In some planes, especially in the 1960s, the throttle, mixture and propeller governor levers have a round, ball-like top. The "dashboard" or front of a cockpit is called the firewall. When a pilot puts these levers in the most forward position (balls to the (fire) wall) they are going into a full-speed dive, taking that plane to its limit. We non-aeronautical folks use it to mean going all-out or doing something with maximum effort. The automotive equivalent of this is "pedal to the metal."
So the next time someone says, "Go balls to the wall" it's still ok to giggle, but now you know it's not as dirty as you think.