Cheesy lines like this are what made the 80's movies so charming. A guy meets a girl, and actually asks her permission to pay for her alcohol. If she says yes, that must mean he's getting somewhere, right?
Well, it can be helpful, or it can be a waste of money; and believe it or not, it can actually hurt your chances with the woman you're talking to. Here's how to tell if you're moving the interaction along, or if you're just being used.
Now was getting her a drink your idea or her idea? If you haven't been talking that long, and she quickly suggests you buy some shots, this is a sign NOT to comply. It's rather impolite and presumptuous to ask a stranger to buy you anything, let alone a drink. There should be some real comfort and connection before you buy her a cocktail.
If she expects you to buy a drink for her friends, it's even worse. That means you're REALLY being used. Just laugh and say "I'm ok for now." Your answer doesn't have to make sense, it just has to be relaxed and slightly amused.
If you've actually gotten to know her, however, and it's your own idea to buy her a drink, you can be a gentleman and go ahead. The main thing is it can't be coming from a place of neediness or trying to impress her. It's fine to be generous.
Buying a girl a drink can be a useful tool to move her away from her friends, as well. When you're talking to her, you can say "Let's go get a drink," and move her to the bar. Once you hit the bar, you can say something like "Let's take a lap" and maybe find a place to for you two to sit and get to know each other without her having to be distracted by what her friends are doing.
Remember to not fall into the trap of buying her drink after drink all night. You may think she's getting wasted enough to go home with you, but all over the nightlife scene you will meet the girl that will let a man feed them a half dozen glasses of alcohol, and not even give him her number at the end.
Overall, it's perfectly normal and social to buy people drinks you meet in bars, both men and women. If you would buy her a drink, even if you knew you weren't going to hook up with her, it's probably a safe bet. This should get you far in your bar nights.