I'm pretty sure that there are no exceptions to this rule of thumb:
ANY defensive building will, after locking on to a target troop (or hero), continue to shoot at that troop (or hero) until:
- The troop dies (includes troops that split into smaller troops, such as lava hounds or golems)
- The troop walks out of range of the defensive building
- The Archer Queen uses her hero power
- The defensive building is destroyed
- The defensive building runs out of ammo (in the case of XBows and Inferno Towers)
So, to answer your question, no the tesla will not switch to the PEKKA until the golem either dies or walks out of range.