It's very possible, I just tried it.
You need "Tasker", with which you can let your phone do tasks when certain criterias are matched (Location, USB plugged, Time, pretty much everything a phone does).
Just create a new profile, choose "State" as context and "Power" as state. There you can define the power source. Choose "Any". Under that field check "Invert". This will perform that task if the phone is NOT on AC or USB power.
After that, you can choose what your phone has to do when those criterias are matched. In the lower left corner, click on the plus-symbol. Then choose "Alert". In this menu, you can choose which Alert the phone should show (Flash, Notify, Vibrate, Flash LED, Play Sound, etc.)
Choose "Notify" and type whatever you want in the Textbox. Something like "Close the USB port, fag!" will be fine. Choose an icon that shows in the taskbar, scroll to the bottom and tap "Done".
Then tap "Done" another time and you are nearly finished. You will get to the main menu again. There just tap "Apply" and you are set.
The notification will arrive instantly in case you are not connected to a USB cord. Just erase it and everything will work.