In D&D 3.5, what are the rules for being trained in spell casting, swordsmanship, etc? I want the party to find an orphan who had been abandoned when his home town was raided. I want the kid to have no combat knowledge but have to be trained by the PCs.
This is the kind of thing the DM handwaves away. The rules make it impossible for a creature lacking racial Hit Dice that advances exclusively by level not to have at least 1 level in a class, usually, unfortunately, commoner. Being a level 1 commoner might as well be the same thing as having no combat knowledge; ignoring the orphan's ability scores, the orphan'll be proficient with 1 simple weapon, have 8 skill points, no base attack bonus, no bonus to his saving throws, and all of 2 hp. Because he already exists, though, he does have his starting feat... maybe even two. He remains alive because PCs don't look at him too hard.1
But, with some work, the PCs can turn the little scamp into someone who can contribute. The PCs'll probably have to hold his hand, though, because
Following the Rules as Written to "train" an NPC is extremely dangerous for the NPC
The only rules-as-written thing the PCs can do to "train" the orphan is include the orphan in their adventures. Having the orphan participate in encounters gets the orphan an even share of the encounter's XP value (DMG 36-7), but the DM must rule the orphan participated in the encounter. (Stuffing the orphan into a bag holding when the encounter begins may or may not count.2)
The 4 5th-level PCs and 1 1st-level NPC survive an encounter with 1 Challenge Rating 6 creature. Each of the 4 5th-level PCs earns 450 XP, but the 1st-level 1 NPC earns 540 XP. Another encounter like that takes the 1st-level NPC to level 2!
When the orphan has XP enough to advance a level, the DM makes any decisions about how he gains that level as the DM controls all of the campaign's characters but the PCs. If the DM decides the rambunctious little nitwit continues taking commoner levels, there's really nothing the PCs can do about it except look on in horror.
Persuading the DM: Some Options
Broadly speaking, there are two alternate ways that PCs may persuade the DM that the orphan shouldn't take his next level as commoner. Neither are very good in that the PCs still have no influence over the NPC and both are meant for PCs rather than NPCs. I present them here mainly so they can be disregarded and the DM can simply dispense with this process instead.
Option 1: Make the orphan take the feat Apprentice (DMG2 176)
Upon reaching level 3, the orphan takes this feat, selecting a PC as a mentor. The PC need not have the feat Mentor (DMG2 176), but won't get any of the benefits from being the orphan's mentor if he doesn't. In fact, it's probably funnier if the PC doesn't have the feat Mentor so the kid spends time training around the PC he's selected anyway, copying his moves, vying for his attention, and probably just making a nuisance of himself. That's fine, genre-appropriate, and gives the player an opportunity to assume the grizzled veteran role normally assumed by NPCs.
This is, I admit, an unusual reading of the feat Apprentice, which is intended for PCs rather than NPCs and reading the feat this way requires switching around much of the jargon associated with the description. It doesn't help that the description of the feats Apprentice and Mentor is deeply fiddly, likely to cause frustration and dismay, and goes on for five pages.
I don't recommend this option both because it's a bookkeeping headache and relies on a counterintuitive reading. Further, you'll probably eventually end up--if the DM doesn't handwave it away after reading those rules in the Dungeon Master's Guide II--using the option below anyway.
Option 2: Accompany the orphan on his Rebuilding Quest
The Player's Handbook II describes the processes of Retraining (192-5) and Rebuilding (196-9). These are usually options for players who have made regrettable character choices or want to play something different but want to keep the character's background. Retraining and rebuilding are usually used by high-level characters, but to rebuild one just goes on a DM-designed Rebuild Quest that
should excite and frighten players. It’s an adventure few characters would willingly embark upon and fewer still could survive. To make rebuilding an option at all levels of play, however, the degree of challenge must change according to the PCs’ level. (199)
Luckily, as the orphan is an NPC Commoner 1, the rebuild quest that the DM designs could be pretty short and--from the PCs' perspective--utterly tame. In fact, such a quest could reasonably be an encounter with the PCs.
I don't recommend this route either unless everyone's idea of fun is escorting the NPC scamp as he fights his way through dire rats with his dagger only at the end to emerge battered yet reborn as a 1st-level sorcerer.3
This is, of course, barring shenanigans like taking the commoner-only flaw Chicken Infested (Dragon #330 87) while simultaneously getting the skill Handle Animal to the point where the character rears and trains rocs. But optimizing commoners is an exercise usually better left theoretical.
Although this DM would lean toward may. If a character must expend his actions to keep alive another character, the other character has participated in the encounter, albeit to the party's detriment.
Note that the DM may rule that it's possible for the PCs to create encounters for the NPC. Traps are easiest, with a camouflaged pit trap (CR 1) (DMG 70) costing a weirdly-high-but-nonetheless-affordable 1,800 gp. A commoner who encounters such a trap 3-4 times (not, one hopes, in a row) gains a level. What encountering means in this context I leave to the imagination.
Okay, I admit, that could be fun once. Once.
There aren't really rules on handling non-combat training, except...
...if they train him for a while (how long "a while" is is entirely up to you) before they take the Leadership feat, you can assume he reached the maximum level for that PC's starting cohort, if you want. If someone in the party already has Leadership when they find him, you can slot him into the 1st level followers as a named follower and when you reshuffle followers (because of a Leadership score change or a big fight killed several or whatever) promote him as needed to represent his growth until he eventually becomes either a top-tier follower or a cohort to one of the PCs.