I am planning to take courses in Mathematics, Computer Science from a US University. I am not in the USA.
How should I generally go about it? Is it an online degree that I am looking for?
And I would like to get a degree for that.
In mathematics, some graduate degrees are offered online, but you should be careful. There are real advantages to doing it in person, and most of the schools offering online degrees are not well respected, so if you select a program based on internet advertising, you will probably waste your money without learning very much or ending up with a valuable credential. (It's depressing how many businesspeople view distance education as just a money making opportunity, without any serious commitment to doing a good job. When you investigate online education, please keep in mind that many web sites are trying to sell you something of questionable value.)
One respectable example is the University of Washington, which offers an online M.S. in applied mathematics, and there are some others like this. They could be viable options if attending in person is impossible. I do not know of any well respected math graduate program from a 100% distance education university in the US, so you should be very suspicious of such programs, although perhaps they exist in other countries (Open University?).
There is no worthwhile online Ph.D. program in mathematics. If your only goal is to get the degree itself, for example to move up in a salary scale for a job you already have, then it might be possible, but you would have to look carefully to make sure the program is accredited, and even so it won't be an impressive addition to your CV. If you are hoping for a career in academia or industrial research, don't even think about an online Ph.D. If an institution offers an online Ph.D. in mathematics, and presents it as being just as good and respected as a traditional Ph.D., then you should be extremely suspicious of the entire institution.
As for computer science, I don't know as much about online master's programs, but the issues are similar and I imagine the conclusions are as well. The online Ph.D. situation is definitely the same as in math.