In the traditional terminology of morality/religion, chastity meant limiting all sexual acts exclusively within marriage (i.e. with one's spouse only), and keeping one's sexual thoughts and feelings under control and in what was considered to be their proper place (i.e. not letting them dominate one's life). Some religions encourage total abstention from sexual acts for those capable of it; for example, Roman Catholic priests and nuns are obliged to be completely chaste.
In BDSM usage, enforced chastity (in the sense of externally-imposed denial of the free use of one's genitals) is a common fantasy, often implemented by chastity belts (or other chastity devices), chastity piercings, or orgasm denial.
The word "chastity" is derived from the Latin castus, "pure, unsullied". A similar concept is "celibacy", abstaining from marriage or sex, usually for religious reasons; this comes from the Latin caelibatus, "state of not being married".