Check your voltages at the pump terminals under both conditions.
If you have an alternator, you might be delivering considerably more voltage to the pump with the engine running than with the engine off.
Also check for a high resistance hot lead or ground on the wiring to the pump. It might not carry much current engine off, but with full system voltage (assuming alternator puts out 13.8+ volts) you might over power the high resistance and deliver adequate voltage to the pump engine running.
Electric fuel pump fuel flow rate, can be significantly affected by supply voltage variation.
Larry