As Solok has stated, juniors in charge of senior officers happens in ST and even today. As for who should be CMO in cases like the one described, it would be the senior member of the department.
I realize that means that sometimes a Counselor would command a doctor, just like a Surgeon may be in command of emergency personnel or pediatric personnel today, or the other way around.
I think we need to make two important distinctions here:
1. It's about Chain of Command: If it is decided (by the folks here, and then by the CC) that the CMO is in charge of Medical AND Counseling officers, then their
position takes precidence over rank. At least,
this is how I understand Navy operations. (If someone knows differently, please, by all means, bring that to our attention

)
This seems to be reinforced by, for example, the self-destruct sequence for a vessel on Trek. It was, as far as I could tell, the duty of certain officers due to their position and not their rank, that they could authorize a self destruct. On the other hand, it's pretty clear that in an emergency, when the highest ranking officer dies, the next highest ranking officer moves into the position of leader. So hmm.
:-\
2. Remember IC/OOC: What's more important, I believe, is the difference between IC and OOC. Everyone has an OOC rank -- the highest rank they've achieved in their career in UFOP. What rank your character is doesn't matter, as long as it's not higher than your OOC rank.
So, it's important to recognize that even if you, as a Counselor, are higher in rank than the CMO, you would still OOC, hold the authority. IC, however, I think it would be in everyone's best interest to follow the chain of command as it is (or would be) set up.
Has anyone been in the Navy? If so, do we have an "authority" on how the chain of command works? -- Rank or Position?