A drug's label, developed by the FDA and the drug's manufacturer, describes the drug's appropriate indications (the conditions it's intended to treat), dosage, route of administration, and other details to guide its use. A label will only contain indications for which the FDA has determined the drug is sufficiently safe and effective.
A drug may be prescribed off-label if a physician believes that a patient will benefit from its use, regardless of FDA-approved indication. The anti-depressant doxepin, for example, is also a strong antihistamine and is sometimes used to treat severe allergic reactions. While it is legal for a physician to prescribe a drug off-label (unless it violates ethical guidelines or safety regulations), a manufacturer cannot advertise a drug for anything but its FDA-approved indications.