I was eating a sub today and was just curious!
Submarines that go into the water existed for centuries (one design was even used in the American Revolution). The sandwich by that name only came around or after World War II. According to America Eats Out by John Mariani: "During World War II, the commissary of the United States Navy's submarine base in Groton, Connecticut, ordered five hundred hero sandwiches a day from Benedetto Capaldo's Italian deli in New London, where the name 'sub' was soon applied to the item."
According the the Oxford English Dictionary, the first print reference for the word "submarine," as it applies to this sandwich, was published in 1955. However there are reference to "sub" sandwich dates to World War II in an article called "The Submarine Capitals of the World" by Jamie Kageleiry:
"The good folks fo Groton have posted a sign, "You are Entering the Submarine capital of the World," to eliminate confusion, because some people believe that New London, across the Thames River, is the sub capital. And it is, sort of. It's the capital of submarine sandwiches, being the birthplace of that wonderfullly portable meal..."