India does have a well-documented problem with sexual assault and harrasment directed at women. So I start off with the basics:
- Try to avoid walking on streets that are not well-lit. This can be more of a problem than you think because the infrastructure in sections of big cities and / or smaller towns can be bad.
- Know the emergency numbers. Police can be reached on '100' nationally (and they can also contact ambulance services if needed); additionally, most mobile networks will also automatically forward calls to '112' (the international GSM emergency number) or '911' to the right number.
- There are specialised hotlines for women to seek help in non-emergency situations. While this is not yet national (but there are plans to expand it), Delhi Police for instance has a special hotline staffed by female police staff on '1091'. Other women help hotlines in India for a variety of situations is listed here.
- When travelling by public transport such as trains, buses, metro et al, try to choose coaches / seats reserved for women. Groping or sexual harrasment can somtimes be a problem. The advised strategy is to raise an alarm if this does happen. Most buses have reserved seating for women and women-only coaches can be seen commonly on many trains too. (We had a question earlier on Travel.SE on female travellers on Indian trains.)
- Be careful about drink spiking incidents, since that's common in some places, especially Goa. I feel on this particular count, India is quite like Thailand as that's another place you have to be really careful to ensure your drinks are not spiked, especially at beach parties. Use your caution and try to get drinks directly from a bartender, don't let your drink out of sight, don't let strangers buy you drinks - standard, common-sense precautions.
There is a perception that foreign female travellers have 'loose morals', a weirdly Indian term which I think shows contrasting attitudes towards casual sex in Indian culture traditionally (sex before marriage is still taboo in the eyes of many people; most marriages still happen to be 'arranged') versus "the West". This might result in unwanted attention leading to sexual harassment. Now, there's obviously no 'right answer' to how to handle this but explicitly asking someone to back off works in most cases of harassment.
For more serious cases which you think might lead to sexual assault, if you're travelling solo or in a small group then then you may want to consider carrying some means of legal self-defense such as pepper spray. (I remember reading the newspapers there that this was apparently outlawed at some point, but it no longer is. Sorry, I can't find a citation for this.)
At the same time, it's also important - I feel - not to get over-paranoid. Indians (Asians in general?) have a widely different concept of personal space compared to most other cultures - both in physical proximity and in how inquisitive people can be about your life. Try not to be creeped out when complete strangers ask you about your personal life, it's what goes for small-talk in India (instead of, say, the weather).
Another thing that you might find while travelling in India, which I hear very commonly from many travellers - but which might seem threatening to female travellers - is that complete strangers may want to get pictures taken with you. You'll find this happening more the smaller towns you go into, but even in big cities as a lot of population in these in the recent decades have been migrants from smaller cities / villages. Many of them have hardly interacted with foreigners - or may be meeting one for the first time - and coupled with differing sense of space / inquisitiveness, it's very likely that you'll attract a lot of attention when travelling.
TL;DR: You will attract a lot of attention as a foreign traveller - female or regardless. Be prepared for this, don't let it make you paranoid. At the same time, be situationally-aware and if you feel things get out of hand, ask people to back off explicity and / or seek help from emergency services.