In the United States Armed Forces, a line officer or officer of the line is a U.S. Navy or U.S. Marine Corps commissioned officer or warrant officer who exercises general command authority and is eligible for operational command positions, as opposed to officers who normally exercise command authority only within a Navy Staff Corps. The term line officer is also used by the U.S. Air Force and U.S. Coast Guard to indicate that an officer is eligible for command of operational, viz., tactical or combat units. The term is not generally used by officers of the U.S. Army – the roughly corresponding Army terms are basic branch (e.g, Infantry) and special branch (e.g., Medical Corps) qualified officers, although the concepts are not entirely synonymous, as some Army special branch officers (e.g., Judge Advocate General's Corps) are eligible to hold command outside their branch specialty.
Officers who are not line officers are those whose primary duties are generally in non-combat specialties including (depending upon the service) attorneys, chaplains, civil engineers, health services professionals, and logistics and financial management specialists. A line officer may hold authority over a non-line officer of higher rank by the nature of their assignment or appointment/succession to command, but is otherwise expected to observe normal customs and courtesies outside that role.
See explanation of staff and line.
The expression "officer of the line" is possibly derived from the 18th- and 19th-century Royal Navy term for capital ships, then called ships of the line. The name stemmed from the practice of employing sail-powered warships in line formations to maximize the effectiveness of side-mounted cannons. 
In the United States Navy (and USN Reserve), line officers are divided into unrestricted line officers, limited duty officers, and restricted line officers. Unrestricted Line (URL) officers hold combat warfare specialties as Naval Aviators and Naval Flight Officers, Surface Warfare Officers, Submarine Warfare Officers, and Naval Special Warfare/Naval Special Operations (NSW/NSO) officers (consisting of SEALs, Special Warfare Combatant-Craft (SWCC) Warrant Officers, Explosive Ordnance Disposal (EOD) officers, and Navy diving officers), and are eligible for operational combatant command at sea, as well as command of major installations and commands ashore. Restricted Line officers command only within their particular specialty, and are normally in fields such as intelligence, cryptology, oceanography/meteorology, engineering duty, aeronautical engineering duty, aircraft maintenance, public affairs, etc.
Navy Limited Duty Officers and Warrant Officers whose technical specialties fall within a staff corps are considered staff corps officers, while all others are classed of the Line. Line officers wear an inverted gold star above their rank stripes on their dress blue uniforms and, in the case of Captains (US pay grade O-6/NATO OF-5) and below, on their shoulder boards in whites. Line officer flag officers (admirals O-7 to O-10/NATO OF-6 to OF-9) will wear solid gold shoulder boards with a silver metallic thread anchor and one, two, three, or four silver metallic thread stars below the anchor. When wearing khakis or utility/working uniforms, they wear their rank insignia on both collar points. The Navy refers to non-line officers as Staff Corps officers. (Both line and staff corps officers may be assigned as "staff officers" serving on the command staff of a senior officer.) Staff corps officers wear their corps insignia, rather than the line officer star, placed over their sleeve/shoulder board stripes on their dress blue and dress white uniforms, and on their left collar point on khakis and utility/working uniforms in lieu of matching pin-on rank insignia on the right collar point.
In the United States Marine Corps (and USMC Reserve), all officers – including warrant officers and limited duty officers (LDOs) – are line officers, trained to command combat units, although Marine officers cannot command ships or shore organizations of the Navy. Unlike the Navy, the Marine Corps does not have any staff corps, consequently all Marine engineer and supply officers, and judge advocates, are line officers. The Marine Corps has no medical corps officers, dental corps officers, nurse corps officers, or chaplain corps officers. Because the Marine Corps is a service within the Department of the Navy, these staff corps billets in the Marine Corps are normally filled by US Navy staff corps officers in those specialties, serving alongside Marines in Marine units, although officers of the commissioned corps of the Public Health Service may be detailed, as well.
In the United States Air Force (and USAF Reserve), officers assigned to the medical, nurse, dental, medical services (healthcare administration), biosciences, Judge Advocates and chaplain corps are professional officers. In addition to being professional officers, Judge Advocates in the Air Force are also considered line officers and, like all other officers in operational/combat and combat support specialties, belong to the Line of the Air Force (LAF). The Air Force has no warrant officers.
All commissioned and warrant officers of the United States Coast Guard and United States Coast Guard Reserve are considered line officers. They wear the US Coast Guard shield in lieu of the inverted star of US Navy line officers on their shoulder boards and above the sleeve braid on dress uniforms. Like the US Marine Corps, the Coast Guard does have line officers serving as judge advocates, but has no officers serving as chaplains or in the health-care fields. Therefore, US Navy staff corps officers (from the chaplain, medical, dental, and nurse corps) may be detailed to serve at Coast Guard units, and are not Coast Guard line officers. These individuals do wear the Coast Guard uniform, albeit with some differences. Additionally, US Public Health Service commissioned officers are the primary source of health care officers in the Coast Guard, serving alongside U.S. Navy staff corps officers and Coast Guardsmen in Coast Guard units. They too will wear the Coast Guard uniform, albeit with some differences. Health services officers in the USPHS commissioned corps detailed to the Coast Guard represent many disciplines, including the biological, physical, environmental, and social sciences; medical technology; health care administration; and other public health specialties such as physician assistant.
The expression "line officer" is no longer current in the Royal Navy and Commonwealth affiliates. Officers trained in the "Executive Department" of a warship are the only ones trained for command. In the Royal Canadian Navy, officers in the Naval Warfare Officer (NWO) occupation hold a similar function, but are not distinguished by any identifiable badge.
1030. Authority of an Officer of the Marine Corps Over Naval Forces. Officers of the Marine Corps may not command ships or Navy shore facilities. This article shall not be construed to prevent an officer of the Marine Corps, when so detailed by the Secretary of the Navy or a commander in chief (sic), from having and exercising such authority as may be necessary to direct the operations of all forces assigned to him or her.
This article incorporates text from this source, which is in the public domain.