The spark you see is completely normal, it has to do with inductance. Any wire loop, such as a transformer, has an inductance. In this case, the transformer has a magnetic field (or lack of one), and when you plug in or unplug the cord, the current flows/stops and the magnetic field changes. Nature abhors a change in flux (change in the amount of magnetic field) and a counter-current is induced by the inductor. This current causes the spark. You'll see this on most battery / charger connections. The laptop industry dealt with it by shaping their chargers and shrouds so that you just can't see the spark when it happens.
The important point here is that you are not going to harm your bike or yourself from this small spark. This behavior is normal and expected, at least some of the time.