In most cases, yes, especially if the institution is offering the same credit course both online and face-to-face. But what if you take an online course at an institution other than the one where you are seeking a degree? Usually, there is no distinction on transcripts between online courses and on campus courses. If you have any doubt, however, be wise and check in advance with the registrar, adviser, advising center or other appropriate party at your credential-granting institution.
Another word to the wise: Even though you may be able to transfer a course for credit to your credential-granting institution, it may not articulate (or count) toward your degree program. So you want to ask a two-part question to the appropriate party: will it count and how will it be counted (general education, major, or elective)? Again, check in advance when you wish to transfer a course.