RobertS, As I understand your question it is for sewer lines; not the backflow for water lines which is always required. For the townhomes we manage there is a main sewer line (12'-14' deep). The main line connects to a service line which connects to each of 2 to 8 units per townhome building. The HOA is responsible for the service line and the individual owners are responsible from the common service line into their individual unit. When there is a blockage in the common service line it will flow back into all of the units. If the blockage is in the homeowners individual line the back flow will be only in their unit. There can be several reasons for a blockage, including - tree or vegetation roots; items owners put down their sinks, stools, and drains; and a pipe disconnect or belly caused by the ground movement.
A sewer back flow valve or a check valve is usually placed just outside the unit, before it connects to the service line, to protect against backflow into all openings within the unit. I received an estimate of $1200 to place a backflow valve at an estimated depth of ~2'. Also, a flood guard could be placed in the basement drain (or other lowest access for backflow) at estimated cost of $200; plus a water alarm can be installed to forewarn to call the plumber. I understand the check valve is more foolproof and more expensive than a back flow valve. And if a snake goes through a back flow and is being retrieved the flap will close on it (so the plumber must be forewarned).
So much for my unfortunate education on this subject. I have yet to have actual experience but am afraid it is coming