Well, first off, Rosemary isn't meant to be an indoor plant. So that's your first hurdle/problem. Second, it's difficult to tell you what you're doing wrong without first knowing what you're doing - lol.
If you still want to try, your best bet is to read up on the plant & find out how you are &/or are not meeting its basic needs. For instance, Rosemary, being of Mediterranean origin, enjoys the same conditions as those regions - excellent drainage, full sunlight (6-8 hours/day, preferably unfiltered by glass), warm dry temperatures. Too much humidity, not enough light or drainage, overwatering can result in any number of fungal problems & root rot. Err on the other side, & your plant will simply dry up.
I've been growing herbs for over 30 years, & Rosemary has never been one to do well for me indoors - even in a dry greenhouse-like environment. The best I've been able to accomplish has been to overwinter a few less hardy varieties so that I could put them back outside in the spring.
Also, keep in mind that even if you get Rosemary to survive indoors, it will grow unbelievably slowly & it's doubtful you'll get to harvest much, if any, without killing the plant. Most varieties of Rosemary are hardy in Northern Virginia - is there a good protected southern-facing spot outdoors where you could plant it?