It usually is free if space is available and you don't annoy the professor. I've had several non-paying students; the only time I ever kicked one out of class was because we ran out of seats.+1 to this - when I was in school, I was never denied a seat in a class that I wasn't officially enrolled in (I took maybe 6 or 7 extra courses that way - oddly enough, I was kicked out of some classes I enrolled in, for space/seniority/in-major reasons), and I always asked the professor before sitting in (I probably could have gotten away with not doing that, since in the math/science departments half the professors don't bother to learn names anyhow, but asking seemed like the polite thing to do).
Some of the most interesting stuff I learned was in those classes, and it's actually how I ended up getting back into programming (I hadn't programmed since middle school)...it's a great way to sample stuff outside your major without needing to worry about doing badly in the classes.
I know people that do this sometimes even as non-students, and they've told me that most professors don't usually mind, though occasionally they'll say no.