It's actually Apple's lovely design. When you connect to MDI or another power source, generally is also connects the audio output of the iphone to 3 pins in the Ipod connector. The iphone automatically switches audio output to that port and switches to accessory control mode. Its stupid.
I heard one method of fixing this was to get a iPod Cable extender and cut all the wires but the charging wires but that just seemed like overkill.