The diamondback moth Plutella xylostella is a serious pest of crucifers. It has high reproductive potential and is resistant to many insecticides. Typically, the last-instar larvae of P. xylostella, before pupation, move to the lower or outer plant leaves to make a loose silk cocoon and pupate inside for adult formation. To better understand this pivotal stage we studied the cocoon-spinning behavior of P. xylostella and measured three successive phases by video-recording, namely the selection of a pupation site, spinning a loose cocoon and padding the scaffold cocoon. Subsequently, we cloned three fibroin genes related to cocoon production, i.e., fibroin light chain (Fib-L), fibroin heavy chain (Fib-H), and glycoprotein P25. A spatio-temporal study of these three fibroin genes confirmed a high expression in the silk glands during the final larval instar silk-producing stage. In parallel, we did an exogenous treatment of the insect molting hormone 20-hydroxyecdysone (20E), and this suppressed fibroin gene expression, reduced the normal time needed for cocoon spinning, and we also observed a looser cocoon structure under the scanning electron microscope. Hence, we demonstrated that the expression levels of key genes related to the synthesis of 20E [the three Halloween genes Spook (Spo), Shadow (Sad), and Shade (Shd)] decreased significantly during spinning, the expression of the 20E receptor (EcR and USP) was significantly lower during spinning than before spinning, and that the expression levels of CYP18-A1 related to 20E degradation were significantly up-regulated during spinning. The significance of the cocoon and the effects of 20E on the cocoon-spinning behavior of P. xylostella are discussed.