Yes you can, though be aware that not all credits will transfer. If you're taking online classes with the expectation of just learning, then that's fine, go ahead. Also then ignore the rest of what I'm writing:
If you're specifically doing it to try to graduate early from college, pay special attention to credit transfer, etc. Also the latter will probably not be free... any accredited brick and mortar place is probably not going to accept free online credits from anywhere, even if they do accept online courses transfer.
Most Unis will have specific sections of their website talking about transfer credits. Figure out what Uni(s) you're looking at for undergrad, and look up the options there.
As to where to look for courses, see e.g. https://www.edx.org/, Khan Academy, Coursera (though most of coursera's aren't free I think), etc.