Your role as a commanding officer is to lead your men. You do whatever it takes to lead them, at all times, and without exception. There's one thing that can stop you from performing your duty (leading your men), and that is when you get shot. When you get shot, you end up laying on the ground screaming in pain, and in such a state you are useless to your men. Not only are you useless but you also endanger your men's lives because you leave them without your superior leadership. As you can see, getting shot while performing leadership duties is a highly irresponsible thing to do. This is why you have to do whatever you think is necessary to avoid getting shot.
Avoiding getting shot usually means you stay in the rear and avoid attracting any unwanted attention to yourself. Don't forget, your job is to lead, your men's job is to do the hard work. Of course, you should engage targets of opportunity, but without breaking the previously mentioned rule (don't get shot). When you get shot, you have only yourself to blame for putting yourself in that position (on the ground, screaming in pain). Don't put yourself in that position. Instead, put yourself in a position where you lead your men to victory (preferably, all of your men).
This is a universal rule of leading, so remember it.
What this means for me, is that I stay in the rear and take pot shots at enemies. I also do rear gaurd duty, I engage any enemies who end up behind my army's formation. Usually this means I chase enemy cavalry who run behind my musketeers. Near the end of the battle (if I'm winning), I move to the front line and join the battle myself, but I prioritize fleeing enemies because they don't fight back, meaning less risk of me getting killed at the last moment. Generally, I try to make myself useful while reducing the chance of getting killed to a minimum.