Can you target sleep at particular creatures?
No, sleep has an area effect and doesn't allow you to choose creatures as targets (you instead choose a point in space). Everyone in the area of effect is potentially affected.
However, the 4 HD limit and its rule that it affects lowest HD creatures first means that sometimes you can cast it on an area that contains both allies and enemies and be fairly sure that it will only affect the enemies. In the case of two stirges attacking a character, two stirges have 1 HD each and so will soak up 2 HD of the effect's limit. Therefore if the character they're attacking has 3 HD or more, the stirges will be affected by the spell but the character they're attacking won't be.
In the case you present, where the character being attacked has only 2 HD, they will be affected by the spell and have to make a saving throw to avoid falling asleep, just like the stirges.
Can you place the area of effect of sleep to only affect the stirges?
No, the stirges occupy the same space as the creature they are latched onto. Once a stirge has attached to a creature and started to drain, it's too late to use clever placement to catch only the stirges in the area of effect of sleep (or any other AoE spell). Character B would have had to cast it on an area containing only the stirges before they had latched onto character A.
In other situations, sleep can affect only your enemies by clever placement of the centre of its effect, yes, assuming the allies and enemies are not inconveniently placed to make this division impossible.