I don't know if I can set the camera's focus to infinity to avoid the blurring effect when I don't want. For example, when I want to take a picture that both background and subject is clear. Currently I can only choose, blur background or blur subject.
The thing you're trying to control is called depth of field, which refers to the range within which objects are acceptably sharp. Infinity, in optical terms, is the position at which the lens will form a sharp image from parallel rays entering the lens. More practically, infinity is where distant objects will be in focus. It doesn't mean infinite depth of field, though. To create a sharp image of close objects, the lens has to be adjusted, and that causes distant objects to go out of focus.
Depth of field depends on a number of factors, including: focal length, aperture, and distance to subject. For any given lens, smaller apertures and larger distances to the subject give greater depth of field. So, there are two options if you want two objects at different distances to both be in focus:
You might think that using a different lens could help: if increasing the distance to the subject increases depth of field, you could just back away and use a longer lens to compensate. It turns out that that doesn't work: if you adjust distance to keep the size of the subject the same, the depth of field will be the same. For example, a 50mm lens 10 feet from the subject and a 500mm lens 100 feet from the subject will both make the subject the same size in the photo, and they both have the same depth of field at any given aperture. However, it's a little more complicated than that because wider lenses have shorter hyperfocal distances, i.e. the "infinity" setting is closer, so a wide angle lens can, in fact, make it possible to put nearly everything in focus. But it also changes the composition of the photo pretty dramatically.