Bees
Most species of bees build cocoons in their nests. The queen lays eggs that hatch into larvae. When the larva transitions to the pupa stage, it builds a cocoon. Some species of mites prey on bee pupae. The mites invade the bee colony during the larval stage of development and wait until the pupae build cocoons. The mites then lay their eggs in the bee cocoons and the mite larvae feed off of the bee pupae. This is a classic example of a parasitic relationship.
Ants
Lycaenid butterflies and some species of ants have a mutually dependent relationship--called mutualism in the scientific literature--centering around chrysalids, the butterfly version of a cocoon. While ants do not build cocoons themselves, they position themselves near butterfly chrysalids and fend off predators. The ants then feed off of sugary liquid produced by the chrysalis. The common imperial butterfly actually builds its chrysalis inside ant colonies in order to obtain protection from ants.
Wasps
Like bees, most species of wasps build cocoons inside their nests. Some species of wasps use the abandoned cocoons of other wasps. Metallic blue wasps look for damaged, empty nests, then lay their eggs. They repair the damaged portions of the nests with mud.
Beetles
Numerous species of beetles build cocoons in the ground. Scarlet lily beetle larvae feed on the undersides of leaves during the first several weeks of life. As pupae they burrow underground and build cocoons made from saliva and pieces of soil. After about about three weeks in the ground, they emerge as fully-formed adults.