If you aren't using a pattern, you can knit a small piece and figure out your gauge, and then using that and how wide you want your afghan to be to figure out how many stitches to cast on. This is somewhat of a trial and error thing.
So say, for example, you cast on 20 stitches and knit for about four inches and your piece turns out to be 4 inches wide (you want to knit for at least 3 or 4 inches so you can get a fairly accurate measurement).
Say you want your afghan to be 48 stitches wide.
48 divided by the 4 inches wide of your trial piece is 12.
Multiply 12 by the 20 you cast on and you get 240 stitches to cast on.
Keep in mind that if you are doing stockinette stitch, it's a good idea to knit 4 or 5 stitches of garter on either side of your swatch where you are going to measure because stockinette curls and will make your measurement inaccurate.
I hope that makes sense!