According to dictionaries, there were rules for the use of the two words, but today we don't distinguish them.
So in general you may choose which is easier for you to pronounce.
But maybe we distinguish them unconsciously.
くらい sounds rather written language, while ぐらい sounds colloquial.
どのくらい時間がかかりましたか？ How long does it take? <-Writing in an E-mail.
どのぐらい時間かかったの？ How much did you eat? <-Asking your friend in person