You are absolutely right that the biggest risk of frequently biting your fingernails is that you might cause an infection. Typically with frequent fingernail biting, the skin around the cuticles and edges of the nail may crack, split, or have small breaks in it. Potentially, all of these openings in the skin are places where an infection could gain access. Also, putting these open skin areas in your mouth raises your risk even more, as the mouth is full of bacteria and other micro organisms.
The most common type of infection that is caused by fingernail biting is something called a paronychia. This is basically an infection of the strip of tissue on the side of the nail, and the symptoms include redness and pain and swelling in the nail fold. Although simple cases of paronychia can generally be treated with warm water soaks and anti bacterial ointment, more severe cases may require drainage of pus or prescription of oral antibiotics by your doctor
If you develop any symptoms concerning for an infection, then you should definitely get in to see your primary care doctor
, who can help you figure out if this is something that needs to be treated.