Sex \seks\ , noun;
1. Either the male or female division of a species, especially as differentiated with reference to the reproductive functions
1. To ascertain the sex of
The noun sex meaning "males or females collectively" dates to the late 14th century from Latin sexus ("state of being either male or female, gender"). There is possibly a link between sexus and secare, which means "to divide or cut," as in 'half' the human race. The definition "quality of being male or female" is first attested in the 1520's while the related verb ("to determine the sex of") doesn't appear until the 1880's.
Surprisingly (to me, anyway), coitus-related usage didn't appear until the 20th century. At least it didn't appear in print until then, you never really know with words like this. Sex meaning "sexual intercourse" is first attested in 1929 in the writings of D.H. Lawrence, but related phrases predate that written record: sex object (1901), sex appeal (1904), sex drive (1918). The meaning "genitalia" is attested from 1938 and sex (something) up is first recorded in 1942. Sex symbol is attested to 1871 in anthropology, but it's modern sense didn't arrive until Marilyn Monroe hit Hollywood in the 1950's.
Related factoid: sexy originally meant "engrossed in sex" (1905), the sense of "sexually attractive" wasn't attested until 1923, replacing the earlier sexful (1898).