Biting usually occurs when babies are at the end of their nursing session. This occurs because the baby starts to get bored. Take your baby away from breast before it starts to bite.
Another reason why babies bite is because they are teething. If your baby is nursing properly they would not bite. So, when your baby starts to bite take your baby away from the breast and give your baby a teething toy. When you do this your baby will eventually understand that the teething toy is for biting and to be gentle when they nurse.