I'm specifically referring to the episode(s) Gambit. In the absence of Riker and Picard, Data takes command of the Enterprise and Worf is second in command.
This seems wrong however, because he is not the next highest ranking officer on the ship. While he was outranked by both Dr. Crusher and Counselor Troi, neither of them would be considered for a command position unless it was absolutely necessary because they were needed elsewhere and had limited bridge experience.
More notably, Geordi would seem to be a more logical choice. He had outranked Worf for around 5 years as he was apparently promoted to full Lieutenant at the beginning of season 2 and Lt. Commander at the beginning of season 3. Worf remained a Lieutenant Junior Grade until Season 3 and made Lt. Commander at the beginning of Generations.
Also, LaForge had commanded the Enterprise on at least one occasion prior to this incident.
Why not have Geordi as first officer? I'm looking for an in universe reason.