Viruses remain in the body for life, however some viruses go through dormant phases when they are not actively attacking the immune system, or the amount of the virus present in the body can be lowered until it is so minimal that it's considered “cleared” from the body.