Because of the novels and movies, the loblolly boy is popularly thought to be crewmember of the Royal Navy, and indeed the term appears in the Royal Navy as early as 1597. However, the rating of loblolly boy also was given in U.S. Navy warships in the late 18th and early 19th centuries, until 1861 when the name was changed to surgeon's steward, reflecting higher training requirements. The name was changed to apothecary in 1866, and changed again in the 1870s to bayman, until medical science at the turn of the 20th century improved enough to make the position much more skilled, renaming it Hospital Corpsman. Across the Atlantic, the Royal Navy name for the rating changed to sick berth attendant in 1833, with the nickname Sick Bay Tiffy (Tiffy being slang for Artificer) gaining popularity in the 1890s.
The name itself comes from the serving of loblolly -- a thick, goopy porridge, sometimes with chunks of meat or vegetables -- to sick or injured crewmembers to speed their recovery. Loblolly, in turn, probably comes from the fusion of lob, a Yorkshire term meaning to boil or bubble, and lolly, an archaic English word for a stew or soup. Loblolly itself eventually came to mean anything sticky and goopy, such as a swamp or bog, and terms such as the Loblolly pine were coined from the muddy habitat of the tree rather than any (dubious) culinary value of the tree's parts.
The loblolly boy's duties included serving the aforementioned loblolly, but also anything that a ship's surgeon was too busy (or of too high of station) to do. This ranged from holding down patients during surgery, obtaining and cleaning tools, disposing of amputated limbs, and carrying out what is euphemistically today called "bedpan duty". Additionally, the loblolly boy performed inventory control of herbs, medicines, and medical supplies.