Anodyne, analgesic and anesthetic all denote something used to relieve or prevent pain, all are freely used both substantively and adjectivally, and all have a related noun, anodynia, analgesia, anesthesia, denoting the corresponding state.
Anodyne is the oldest and most inclusive of these terms; it may be applied to any agent used primarily to relieve pain whether by dulling perception of pain or by altering the pain-causing situation (as by local stimulation of blood flow), often has a literary or popular rather than medical connotation, and is the only one of these terms given broad figurative use (see ANODYNE 2).
Analgesic is narrower in scope; it is applied especially to a medicinal substance or preparation used locally or systemically to dull the perception of pain (as by action on the nervous system) usually without other major disturbance of consciousness.
An anesthetic is a medicinal agent that produces insensibility both to pain and to all other sensations either of a particular part or area (local anesthesia) or of the whole body (general anesthesia): anesthetic is the one term to use of an agent designed to prevent anticipated pain (as from surgery) as distinct from one designed to assuage existent pain; thus, one is administered an anesthetic before a tooth is pulled and given an analgesic to relieve pain after the anesthesia has worn off.