How soon can I ask a girl out?

should you wait until you've spoken to a girl a few times before asking her out? there's this cute girl in one of my classes that i haven't spoken to yet that i want to go out with but in the past i have waited too long before asking girls out. so i decided to instead ask this girl out the first time i speak to her. would this be ok?