Doxepin is used to treat anxiety or depression. It is also used to treat insomnia (trouble with sleeping). Doxepin is a tricyclic antidepressant (TCA). It works on the central nervous system (CNS) to increase levels of certain chemicals in the brain.