In the U.S., the Sheriff is an elected county official. In some states, the sheriff's office is the primary law enforcement agency for areas outside the cities and keeps the county jail. The sheriff, along with constables, serve civil court paper and subpoenas. In some states, the sheriff is only the county jailer. In others, the sheriff runs the jail and has deputies on patrol, but investigations are conducted by another office, such as the state police or so-called "county detectives" who are really state officers. The sheriff is the head of his agency and is independent, being an elected official.
"Marshal" may refer to different positions. In some states, small cities are policed by the town marshal, a peace officer, either elected or appointed. In some places, larger cities have a city marshal in addition to the police department. In that case, the marshal generally serves arrest warrants from the city court for traffic and other minor offenses. There is also a U.S. Marshall Service, one appointed U.S. Marshall in each federal court district and many deputy marshals. They are the bailiffs of the federal courts and serve federal arrest warrants and civil orders and work on fugitive task forces with state agents and assist other agencies with hot warrant services.