The lowly silkworm is of great economic importance, and wars have been fought and empires founded on silk, not to mention Louis Pasteur's career. Pupae in butterflies are called chrysalises. Many moths pupate underground, but those that do spin a cocoon subsequently molt to a pupa inside the cocoon, then molt to adult before coming out. These bite a host, then sponge up the blood. They are wingless and parasitic, with flattened bodies, the better to crawl between their host's hair.
Eggs laid by the females fall off into carpeting, the pet's bedding, etc., where they hatch.
The larvae live in rugs and the pet's bedding and feed on organic material there. Eventually, they pupate in silk cocoons, often in the crevice between the rug and a table leg. Many hymenopteran species are colonial with castes. Generally, workers sterile females, and there are very few males in a colony. Sex is determined by whether the egg was fertilized or not.