1570s, originally of medicines, "that tends to prevent disease," from Middle French prophylactique (16c.) and directly as a Latinized borrowing of Greek prophylaktikos "precautionary," from prophylassein "keep guard before, ward off, be on one's guard," from pro "before" (see pro-) + phylassein, Ionic variant of phylattein "to watch over, to guard," but also "cherish, keep, remain in, preserve," from phylax "guard," a word of unknown origin.
The noun is first recorded 1640s, "a medicine or treatment to prevent disease;" meaning "condom" is from 1943, replacing earlier preventive (1822), preventative (1901). Condoms originally were used more to thwart contagious disease than to prevent pregnancy.