Security duties when there is a Marine presence.
The Marine Corps Commander has stated that the marines serve a certain function on a Starfleet ship:
Ships: In times of peace generally Marines numbers on ships are small, acting as a ever present crack squad, and highly trained Security Force, working hand in hand with Security Forces already present on the ship. In wartime this takes on a more pressing note, and numbers swell, as do ships carrying Marine detachment's, even if small. They provide an additional highly skilled fighting force, who could be called the 24th century equivalent of the Commandos, or SAS.
The marines are to suplement the security force on a starship in the event of a boarding or other hostile action that takes place on board that ship. Duties such as guarding sensitive areas or security patrols are general examples of this. Final authority for Security on a Starfleet vessel rests in the hands of the Chief of Security who then reports to the Captain or Executive officer.
However, on away missions as well as any hostile boarding actions when there is a Marine presence, the Marine Commander will then take responcibility for the safety and well being of the crew assigned. Security may assist as necessary, however the Marine Commander has the authority and jurisdiction.