More seriously, I suspect it was probably more just that muskets were so inaccurate that attempting to aim for any particular man in a formation was pretty much a waste of ammunition, hence it made more sense to order the men to just aim for the big mass of enemy soldiers, in the hope that even if you didn't hit the guy you were aiming for, you might hit the guy next to him. I suspect that shooting at officers was probably considered not so much unsporting or dishonourable as just impractical.

I wonder if this was different for the skirmisher battalions armed with rifles? Did they attempt to target officers?

I believe though that this was one of the problems faced by the British at the Somme; the tactics were based around the assumption that an officer or NCO didn't have a particularly higher chance of being shot than his men, which is fine against musket fire where being hit or not is pretty much a lottery, but with an enemy armed with rifles this was clearly not the case. Hence losses among the officers and NCOs crossing No Man's Land were extremely high, and as such the few battalions which did make it to their objectives had only a vague idea of what they were supposed to do once they got there.