TLDR: If a template is made at character creation it costs xp upfront and no debt is required. If a character gains a template as a reward or something, their xp either gets consumed or they gain debt (their choice).
When dealing with templates, Pathfinder as a base only increases the CR of the creature the template is applied to. This would mean a PC would be able to gain a template with no problems considering a CR increase would not account for a Level Adjust. Since Pathfinder has no real rules for PCs gaining Templates I will make some.
When creating or adjusting a character with templates they are effectively put at an “experience cost” or “experience debt” this means they have to pay this cost upfront on character creation or pay off this debt in order to catch back up to the highest experience character. The templates do no change the characters ECL, they just were made or gained extra pay and as such had to use their experience to pay for it or had to pay it off as they leveled. Determining the cost for the templates is as follows:
Character Creation: 1 + CR Increase = Xp for a character of that level is the cost.
Ex. Tim gaining a CR +3 template would cost as much as a 4th level character or 6,000xp. So to play this character the PC has to subtract 6,000xp from their total xp.
Attained: Level XP for ((Current Level/3) + CR Increase) = Exp Debt
Ex. Geald gains a CR +3 template at 10th level, the xp for a 6th level character is 15,000. They now have a template but also have an exp debt of 15,000xp.
Now that the calculations are out of the way, the character who was made with a template at creation is fine and good and has nothing to worry about, but the character with experience debt has a few hoops to go through now. When they gain experience they cannot gain more experience than the highest level character minus their debt (minimum being their current xp). When they gain experience it can be used to pay off their debt instead of increasing their experience total, this effectively makes it so their maximum capable experience number goes up and later on they can choose to split the experience between total and debt. Another downside to experience debt is that any character who has debt is unable to use the downtime system to gain experience over their maximum and they cannot pay off their debt with experience earned in the downtime system.
So for the above example, Geald is a 10th level character with 15,000 in debt. His exp total has to remain 15,000 below the highest xp party member. So when Tim has 90,000xp, his buddy Geald can only have 75,000 xp at maximum. But Geald is still gaining the same amount of experience as his other party members and as such can instead of increasing his experience total, he can instead use it to pay off his debt. He doesn’t add any experience to his experience total but he knocks off his debt increasing the maximum xp he can have. When he gains experience later and his maximum has increased to a point where he can actually have more xp, he can choose to split that experience to add some to his maximum and some to pay off the debt.