Retraining
You can run a campaign without retraining if you want the PCs to be more bound by their decisions or are running a game without downtime. However, if your campaign doesn't use downtime rules but a player really regrets a decision made while building or leveling up their character, you might make an exception for them by letting them simply change the decision.
Some players enjoy making retraining into a story. Use NPCs the character already knows as teachers, have a character undertake intense research at a university, or ground the retraining in the game's narrative by making it the consequence of something that happened to the character in a previous session.
Time
A character might need to retrain several options at once. For instance, retraining a skill increase might mean they have skill feats they can no longer use, and so they'll need to retrain those as well. You can add all this retraining time together, then reduce the total a bit to represent the cohesive nature of the retraining.
Instruction and Costs
You don't have to use teachers, but it gives you a great way to introduce a new NPC or bring back an existing one in a new role. The role of a teacher could also be filled by communing with the cosmos for a solarian, training with the military for the soldier, and so on. The important part is the guidance gained from that source.
Any costs to retraining by using an NPC should be pretty minor—about as much as a PC could gain by Earning Income over the same period of time. The costs are mostly there to make the training feel appropriate within the context of the story, not to consume significant amounts of the character's earnings. A teacher might volunteer to work without pay as a reward for something the character has already done or simply ask for a favor in return.
Extreme Retraining
Changing an ancestry or heritage requires biohacking or magic, such as reincarnation into a new form. This might take a complex ritual, exposure to experimental biotechnology, or the intervention of a deity. For instance, you might require an ysoki who wants to be a shirren to first become trained in Shirren Lore, worship Hylax, and eventually do a great service for a shirren colony to get a divine blessing of transformation.
Retraining a background requires altering the game's story so that the events the PC thought happened didn't. That can be pretty tricky to justify! One easy scenario is that they had their memory altered or replaced with memories from another timeline and need to get it restored to reveal their “true” background—the new retrained background. They might also be revealed as a clone or parallel self from another reality.
Of course, in all these cases you could make an exception and just let the player make the change without explanation. This effectively acknowledges that you're playing a game and don't need an in-world justification to make certain retroactive changes. Or the justification could be something the player is unaware of until later, potentially tying the retraining into the larger ongoing themes of the campaign. It might be easier, or require less suspension of disbelief, to ask the group to adjust their ideas of what previously happened in the game—retconning events—than to create an in-world justification for something like an ysoki turning into a shirren via magic or a technomancer becoming a witchwarper via reality hopping.