A Rack Focus occurs when the Camera Operator, or a dedicated professional Focus Puller who is assigned only to dialing the focus on the lens, turns the dial of their focus, physically, which causes the lens to force the viewer’s eye to travel to a new image which becomes in focus. An example would be to show something in the background (deep) or the foreground of the shot (shallow), and then the focus shifts to the new thing.
The technique is use to bring attention to something behind, or in front, in the same frame. It can be used to show the audience something the character might not be aware of, or sometimes when a character realizes something is in front of, or behind them. The rack focus can be used in comedy and also in drama. Sometimes it’s subtle - like the sidewalk crowd shot of Dustin Hoffman in Tootsie, or 2006’s The Host, specifically the hospital corridor scene. Other times it can be used in dialogue between two people without the need for an edit point.
The roll of the focus can also be called ‘selective focusing’ a ‘rack’ or a ‘pull focus’, depending on the Director of Photography or whom ever calls the shot.