The short answer to this question is: They don't.
But since this is quite an embarrassing accusation for the ostrich —intentionally self-suffocating?!—let's take a minute to unpack this myth and clear the ostrich's name.
First off, a note about the ostrich: Despite holding the title of the largest living birds—they stand 7 to 9 feet tall when fully grown—their heads are relatively small. This is important because from a distance, ostriches nibbling at food on the ground may appear to have their heads in the dirt.
But the more likely root of this claim has to do with ostriches' nests. Male ostriches dig a sizable hole—up to 6 to 8 feet wide and 2 to 3 feet deep, which is plenty big for their puny heads—in which to stow the eggs. During the incubation period, both mom and dad ostrich take turns rotating the eggs with their beaks, a task that requires them to submerge their heads into the nest, thereby creating the illusion that their heads are buried in the sand.