The first thing to consider is whether the garment is knit in the round or not.
As most of you probably know, even when a garment is knit flat (when you alternate knitting the right side and the wrong side of the fabric, also known as knitting "back and forth") you may still need to (or choose to) use circular needles, especially if the garment is seamless.
This is because you will at one point or another, end up with many stitches on your needle (for example, if the back and the two fronts of a cardigan are worked in one piece) and it could be unwieldy to use long straight needles -- though some people prefer to do this, or use double-pointed needles (it's all about personal preference.)
Another case where circular needles may be more comfortable to use when knitting flat is when you need to knit along a shape that has a curve to it, like a seamless cardigan's yoke, or the front band of a hoodie. For example, the textured band of my Latte Baby Coat is knit in one piece in a U-shape, along both fronts and the edges of the hood. Since it's difficult to knit along an angle with straight needles, the flexibility of the circular needle's cable is helpful.
In either case, you will need to figure out by quickly scanning through the pattern the maximum number of stitches that you will have on your needles for the size you are knitting and convert that to inches (divide the stitch count by your per-inch-gauge). Thankfully, most good patterns include stitch counts and this shouldn't be too difficult to locate.
In a seamless, top-down cardigan like my Hyphen cardigan, this maximum number of stitches will be right before you divide for the body and sleeves.
In a seamless, bottom-up cardigan like my Silverfox cardigan, it will be right when you start working the yoke, i.e. after you join the body and the two sleeves.
There are some exceptions: for example, my Tiered Baby Coat is constructed seamlessly and top-down, but in this case, there is a significant flare at the bottom of the garment, created by two increase rows, and the max number of stitches will be reached after those increases are completed, so you'd have to look at the length of the hem to determine your circular needle size in this case.
Once you have this max number of stitches, you can translate it into inches (by dividing it by your per-inch gauge). Let's say this number is about 30" (or 76cm). Does this mean that your standard, 24" (or 60cm) needle is too short? Well, not necessarily! A circular needle can hold 30-40% more than its length so you have some leeway. This is when it comes down to personal preference: how crammed do your stitches need be on your needles before it starts bothering you?
You start getting a feel for these things: I find that unless I'm knitting a seamless dress or flared out cardigan, a 24" circular needle will work ok for most kid's garments (at least until sizes 6yo to 8yo). After that, a longer cable, like the 36" (or 91cm) may be preferable.
- Garment is knit in the round
In this case, there is less margin for error. If you are knitting in the round, the circular needle length cannot be greater than the smallest circumference of your project.
So, if you're knitting a 3 month garment that is knit in the round, like my Tutu Top for example, a quick look at the schematic will tell you that the finished garment's chest circumference (the smallest part of the body) is 17.5" or 44cm. So, you cannot use a 24" circular needle to knit the body. You need to go down to a 16" or 40cm needle. Otherwise there simply won't be enough stitches to "populate" your too-long cable.
Here's an example in the photo below: can you see that my stitches are a little stretched out? My circular needle was a bit too long for the project but I decided to forge ahead, as I was about to start a series of increases: