An officer of the line, or line officer, was a senior officer that was not part of the normal command structure, such as non-combat staff officers. Unlike a chief engineer, a chief medical officer was not typically considered an officer of the line.
When Commander Montgomery Scott was in command of the USS Enterprise while Captain James T. Kirk and Commander Spock were being held hostage on Vendikar in 2267, Doctor Leonard McCoy expressed frustration with a lack of communication from the surface, Scott asked McCoy what he suggested they do, prompting McCoy to reply, "Me? I'm a doctor. If I were an officer of the line, I'd..." but Scott cut in, stating, "Would you have me open fire?" Leaving McCoy to answer, "Of course not." (TOS: "A Taste of Armageddon") Earlier that year, Spock had presented himself to Dr. McCoy for arrest due to his being the senior officer present at that moment. (TOS: "The Menagerie, Part I")
Prior to the arrival of the USS Enterprise at Farpoint Station, and their official transfer to their new ship, Commander William T. Riker shared his interest with Commander Beverly Crusher in the odd happenings that he had observed there. While Crusher felt that "there are reasons for a first officer to want to demonstrate his energy and alertness to a new captain," she began to indicate otherwise, stating that her "duty and interests [were] outside the command structure..." before the pattern on the bolt of fabric she was looking at changed, adding to the list of odd happenings Riker spoke of. (TNG: "Encounter at Farpoint")