own-sauce Here's some context on what's happening.
If you go to Settings > Security > USB Accessories you'll understand why this works the way it does.
The default is that you cannot connect accessories when the phone is locked. You can also always allow them, or always deny them.