Your Pencil will consume very little power from its battery while it is not being used - whether or not it is attached to the iPad's magnetic charging dock.
However, the Pencil becomes "active" - and will consume battery power - if it detects the slightest movement. The Pencil's built-in accelerometer will power-on the Pencil unless the Pencil remains completely motionless. This motion activation can often result in the Pencil seemingly losing battery charge even though it is not being used with the host iPad. As such, if being carried in a pocket, briefcase or elsewhere, the Pencil will be "in-motion" and therefore using its available battery charge.
While the Pencil remains docked with the host iPad, the iPad will automatically recharge and maintain the Pencil's battery while the Pencil itself is not being used - but only while the iPad itself has adequate battery charge.