How could he be? I'm pretty sure "Acting Ensign" is the lowest possible rank attainable on a starship. Like Chief O'Brien said to Nog, if Wesley ever had to take command, there'd be no one left to command.
Part of the summary of "Pen Pals" in the 2nd season, when Wesley is an acting ensign:
As the
Enterprise surveys an area of unexplored planets with unusually short life spans due to severe geological changes, Acting Ensign
Wesley Crusher is put in charge of a survey team in order to further his studies toward becoming a Starfleet officer. Wesley selects a team of highly competent science officers; however, as they are much older than he is, he worries that his authority will be challenged. One team member, Davies, rebuts Wesley's request to run a time-consuming scan, causing Wesley to doubt himself.
https://en.wikipedia.org/wiki/Pen_Pals_(Star_Trek:_The_Next_Generation)
If Wesley is in charge of a survey team he is more or less in command of it. Since Wesley had people under his command in that episode, and there was at least one person above Wesley but below Captain Picard, Wesley was in the chain of command during that episode.
You mention Chief O'Brien, and yet fail to realize that as a chief petty officer he was more or less an enlisted man, and thus more or less lower ranking than Acting Ensign Wesley Crusher.
As Wesley said in "Datalore":
WESLEY: That everything that I have said would have been listened to if it came from an adult officer. Request permission to return to my quarters, sir.
If Acting Ensign Wesley Crusher was not an officer, he would have compared himself to an adult, not to an adult officer.
And even if Acting Ensign is the lowest possible rank in Starfleet, Acting Ensigns can still be in the chain of command.
In the army, two second lieutenants with the same grade will not have any problem of deciding who is in command of them and any enlisted men with them. The second lieutenant with the earliest date of being commissioned a second lieutenant will have the right to command. If 2nd lieutenant A is in command of a squad or platoon, and 2nd lieutenant B has seniority, 2nd lieutenant A will remain in command of his unit and 2nd lieutenant B will have overall command, the senior sergeant will be 3rd in command, and so on, with a clear chain of command.
And I think the rule of seniority in rank also extends to enlisted soldiers down to the lowest ranks, so that two privates would know who had the right to command.
So I suppose that if in the Civil War a group of drummer boys got separated from the rest of their unit somehow, the drummer boy who enlisted at the earliest date would have command seniority, regardless of his age, if they followed normal army methods.