Hi, I'd like to help you with your question.
I can understand how you feel about your daughter's choice. When you raise your child a certain way, it is hard to find that they choose differently.
I think there are some very good points here. The most important one is that your daughter was willing to be honest and tell you about having sex with her boyfriend. For most parents of a teenager, this would never happen. You appear to have a good and close relationship with your daughter.
Two, your daughter is doing very well in all other areas of her life. She gets good grades, she participates in Karate, and she is close to you. These are good signs that she is on the right path.
What is important right now is to talk with your daughter about what she has learned from her experience. Let her know that you want to talk with her not in a judgmental way, but to help her understand what happened, how she got to that point (her idea, pressure from the boyfriend, etc) and what came out of the experience. Mention the cousin and ask if she felt that influenced her decision. Talk about the fact that other people sometimes view sex differently and treat it more loosely. Then mention the consequences of such behavior- AIDS, sexually transmitted disease, kids with broken homes and different fathers, etc.
Ask her how she wants to handle this situation in the future. This is important since she wants to be prepared in case she faces this again, and with a 17 year old boyfriend, she will.
You may want to let her continue having contact with her cousin. Although the cousin has some bad influence in her life, your daughter has a good relationship with her. She is going to encounter many people in her life who are in the same situation as her cousin, probably worse, and you want her to do this when she is with you so you can guide her in the right way. However, if the situation with her cousin gets worse, consider restricting the contact.
Here are some books that may help you:
A Parent's Guide to Teenage Sexuality by Jay Gale
Young Woman: Christian Girl's Guide to Teenage Sexuality by Jonathan Gallagher, Ana Gallagher, D.N. Marshall and Eileen Baildam
Dilemmas of Desire: Teenage Girls Talk about Sexuality by Deborah L. Tolman
If you find that your daughter is rebelling and you are not able to connect with her, consider talking to a counselor or if you attend church, your pastor. You can find a good counselor by asking your daughter's doctor for a referral or you can search on line at http://therapists.psychologytoday.com/rms/.
I hope this has helped you,