This depends on the nature of the contamination, its extent, and its location. For some types of contamination, you can simply close the doors to the contaminated area before and during cleaning.
However, in other cases, you will have to vacate your home during cleaning. Either the contaminant or the cleaning techniques used might be toxic and hard to contain.