As Nikon D5X00 cameras lack the micro-focus adjustment feature found in D7X00 cameras, viewfinder front focus and back focus problems cannot be fixed by camera settings.
Fortunately, there is an undocumented mechanical adjustment screw inside the mirror box in D5X00 cameras that can be used to correct this problem. This screw has a 2mm hex socket and is found just behind the bottom edge of the mirror on the right side wall of the mirror box.
After shooting test photos of a lens alignment target, determine whether the camera is front focusing or back focusing. The camera should then be put in mirror lock-up mode and the lens removed, exposing the mirror box. To fix front focus, the screw should be turned counter-clockwise. To fix back focus, the screw should be turned clockwise.It should take only about a quarter-turn of the screw to fine-tune the focus system for your lens.