Bladder infection

Around two weeks ago I became sexually active with my boyfriend and we tend to do it a lot and I got a bladder infection how do I get rid of it and is it because of having sex too much?