Additional Variations
While the few officers I've detailed here are Aristocrat/Warriors, this is by no means the only choice available. Military service is seen as a proving ground for young firebrands, eager to make their mark on the world. Advisors and senior tacticians, who may be fighters or wizards, might be given rank and the authority to use it. Paladins may be expected to serve with an army, and their abilities rarely go unnoticed -- it'd be strange to see one as a mere soldier unless his leader ordered him to assume such a lowly rank in order to learn humility.
It is of course entirely possible for a character to hold an officer's rank even if he doesn't have a single military bone in his body! These specialists serve other tasks than simply leading men, and as such may be somewhat alienated from the regular soldiers. They may be mere bureaucrats, surgeons: the list of possibilities is endless. Company chaplains might technically hold the rank of lieutenant or captain. People from all walks of life could assume this role, being officers in name only. Experiment: someone other than a higher-level warrior as a leader could make the encounter more rewarding.
Other Races
Outside of human society, military leaders are selected by different means. Dwarves, traditionally a martial society, often have to contend with goblinoids and other subterranean races, and as such their leaders are expected to spend less time learning their manners and more time acquainting themselves with the practicalities of warfare. By nature a more orderly race, their officers may take advice from sergeants, but they play fewer political games because the safety of their mines or their clans is more often on the line. They live longer and spend longer in training, often learning their tactics by rote. Each soldier is drilled endlessly and knows his role in the scheme of things. Dwarf officers are efficient and exacting, and are respected if not actually liked.
Leaders of elven bands come from a wider variety of backgrounds: their chaotic societies allow for greater social mobility while their indefinite lifespans mean they can acquire a more esoteric skill set. Some even leave their academies (which tend to be smaller, less formal institutions) with knowledge of magic. Much of their training involves learning how to improvise, and they spend more time with their troops, getting to learn their capabilities. They are less inhibited about fraternising with lower ranks, and usually only the officer's abilities distinguish him or her from the rank and file.
Gnomes and halflings, lacking physical prowess and coming from smaller social groups, tend to be less militaristic. They value cunning and guile above simple militaristic might. The greatest problem their officers face is when they have to deal with other races: in the case of their enemies, goblins and kobolds prefer torturing and executing their prisoners rather than talking with them, while the taller folk often find it hard to take gnomes and haflings seriously due to their small stature. They often find it best to play on their apparent harmlessness, settle for a worse deal, then astound potential allies with their sneakiness and inventiveness. They make more elaborate plans, knowing that they can only gain the respect of the bigger people by amazing them with practical demonstrations of their units' abilities.
Conclusion
Officers should be conspicuous leaders. The PCs should be made aware of who is in charge of the soldiers, his name, and his position. Make sure the PCs, if they choose to be observant, learn how the troops respond to their orders. While it's all too easy to view thirty soldiers as a bunch of walking bundles of hostility and small amounts of experience points, the officer gives them a recognisable face. Through the officer, battles become more interesting and the possibility of negotiation and further roleplay is created. Neglect them at your peril!
Of course, officers might come from privileged backgrounds, but not many of them are true nobility. Some, like knights, may fight side-by-side with officers, but have followed a completely different path into military service. More about them later!
