A few more points to add:
My time in the USN was all shore duty (don't ask if you'll get jealous), so I don't have much direct experience with who commanded what but I made several observations about this in relation to my Traveller campaigns.
First off, the USN's job functions are (or were) organized by billets. Each billet is for a specific job, and has a specific set of requirements for filling it. These billets are organized more on an ideal structure, rather than what's available.
The various ranks people have and can promote to are theoretically driven by the needs of the billets - if the Navy needs 200 06s, then it will try and set it's promotion requirements so that they have as close to 200 06's as possible. However, due to all sorts of things - too many people passing their tests, more retirements/losses than expected, etc, the odds of having exactly the number of a given rank that is needed is extremely unlikely.
So when a billet becomes open, the Navy will look first to put someone there who meets the requirements of the billet, and if they can't, will first look "above", then "below" to fill the requirements. That means if a CO position on a Frigate opens up, and the billeting says it should be an 05 with X experience, that's what they'll try and put there. Unless they have an excess number of 06s, in which case an 06 will get the job. However, if they don't have any 06s or 05s to fill the job, an 04 could wind up getting it.
Next - the Navy really likes a top down structure. They like it when the guy in charge outranks the people below him. That means that ideally, if you have an 05 as the CO, then the exectuive officer is going to be an 04, and your other officers will be 03 or lower - the pyramid thing works all the way down.
So the best way to figure out what the "ideal" rank to command a given ship is is to know how the crew on that ship is structured. Departments will be divded into divisions, and typically, every division will have an officer in charge. So if your gunnery department has a division for each weapon type and they have three weapon types, then the minimum CO rank of your ship will be 04 - each weapon division will have a minimum 01, the Gunnery Department will have a minimum 02, which (assuming other departments are similarly arranged) means that the EO will be an 03, and the CO will be an 04.
On small ships with small crews, a Navy may dip into the the enlisted ranks for some of those positions. FREX, the tugboat department I was stationed at had E7s as boat commanders, E6s as first mates, E5s as chief engineer's and chief Boatswain's mates, while the department in charge of all the boats was headed by an 03 and an 01.
To further complicate things, remember there is a difference between Command (or Line) and Staff officers. Only command or line officers can actually hold command of a vessel (or shore station). Staff officers are typically trained in a specialty - the most common one is Medical - and while they can command a department related to their specialty, they'll never command a ship. So you can sometimes have a situation where the CO of a large ship is an 06 or 07, but their medical department is run by someone of the same rank (or rarely, a higher rank).
Then you can make things more fun by comparing Navies. Based on my experience with the USN, USAF, and RAN, it appears that most navies have the same basic structures, it's the details that are different. I'll speak about the differences with the Air Force and USN, since they are the ones I'm most familiar with, but the same principal applies between navies. My cousin and I joined the USN and the USAF within 6 months of each other, and both of us had fairly successful careers within our respective services. However, the USN has a much higher turnover rate in personnel than the USAF does - which led me to making E6 in just over 6 years, while it took him something like 14 years to accomplish the same thing. The USAF has a much, much slower rate of progression. Similarly, the RAN had a slower turnover rate than the USN - when I was stationed at the joint USN/RAN base in Australia, several of my RAN counterparts had far more years in service than I did, yet we were equivilently ranked.
Now, to relate all that back to Traveller, it's easiest to define what a ship's CO needs to be by the number of officers it has and what departments it has. This was pretty easy under the CT/HG rules - HG basically told you how many officers the ship needed and where - you just had to build your pyramids. MgT HG is similar in scope - the only thing I'd add is that generally there are no more than 30-60 enlisted personnel for every officer.
So while ship size _might_ be a good guide, you can probably come up with some better guidelines that are based on crew size and navy type. Navy type is important, for the various reasons I outline above. The Imperial navy, by its size and very nature, is likely to have higher turnover rates and need more personnel than a smaller, stable planetary navy. Even two planetary Navies may have differences - a rich world with hundreds of SDBs, Cruisers, etc may have it's smaller ships commanded by 04s, while a poor world with only 4-5 SDBs will likely have them commanded by 06s and 07s.
Hope all that rambling helps.