You can take online courses (and there is much discussion on this group about that), or you can self study. If your local high school allows it, you can even do that.
If you self study, you cannot put the AP designation on your transcript unless you have your 'course' approved by the AP people. So, you leave AP off your transcript, but put the AP score on your transcript. The Adcoms are smart - they figure it out.
Either way, when it comes time to taking the exam, you will need to set that up through a school. Not all tests are offered at all schools, in fact, a school that offers all is very much the exception. So make sure you will be able to take the exam when the time comes.