else when the speed controller is on the off stage to give current from the external power source to the battery.
You can tie all three of these items to a common voltage bus without any switching other than motor PWM and it will do what you want. If the motor is drawing more current that the external supply can deliver, the bus will draw current from the battery to make up any short coming, and when the motor is not drawing current, the external supply can put current onto the bus that can be consumed by the battery.
You'll just need to make sure the external supply is current limited and that the battery and external supply voltage are compatible.
Keep in mind that the "really fast" you're talking about is usually in the 20-40 kHz range and the capacitors that are placed in properly designed circuits will likely prevent the current flow from doing what you're thinking. But I've never tried it so if someone knows for sure, they can correct me.