There's no intentional wiring that would tie those things together (i.e., last ball, score motor pulsing, and the right flipper), so I can only guess that there's a stray short in the wiring that's allowing the signal to "jump the tracks". One place to look would be the wiring around the score motor switches, given their proximity and how much they're packed in. A stray wire strand, or back tabs touching - something along those lines.
The 'last ball' part of it is curious too though, since there's nothing that logically changes during play while the last ball is active. But the Ball Count unit does have wiring on the wiper disc to indicate when it's on ball 3, 4 and 5 (the bottom pair of wiper fingers). Pretty remote from the flipper though.
The switch at motor 1A is what provides the five pulses for the scoring, when either the 500 or 5000 is scored. The rollovers activate either the D or E relay.
Since it only happens with those, could also manually activate D and E and see which one causes it.
Probably will take some careful visual inspection to track down though.