Tannins are a large group of polyphenolic compounds and natural protective substances for plant survival. The differentially expressed genes (DEGs) of Micromelalopha troglodyta (Graeser) under tannin stress were studied by Solexa sequencing technology. A total of 51,797,038–54,991,822 and 51,674,478–52,307,172 clean reads were obtained from the tannin treatment (TT) library and the control (CK) library transcriptomes, respectively, and assembled into 21,236 nonredundant consensus sequences. The expression of 1,627 unigenes in the TT library was remarkably different from that of the CK library; 885 genes were upregulated, and 742 genes were downregulated (P ≤ 0.001). The expression of 18 DEGs was detected by real-time fluorescent quantitative PCR, and the trend of gene expression was consistent with that of transcriptome data. In the biological process category, the DEGs were primarily related to cellular processes, metabolic processes, and single-organism processes. In the molecular function category, the DEGs were mainly involved in binding and catalytic activity, and in the cellular component category, the DEGs were mainly related to the cell, cell part, and organelle. Pathway enrichment analysis indicated that drug metabolism-cytochrome P450 and glutathione metabolism may be associated with detoxification-related processes under tannin stress, and glutathione S-transferases and other detoxification enzyme genes play an important role in detoxifying tannins in M. troglodyta larvae. This study also provides important resources for further study of the genes related to pesticide targets and metabolic processes in M. troglodyta.