As you've pointed out, the word as is sometimes used to connect two clauses. When as is used this way, it generally means while, when, or because, depending on the context, and it is called a subordinating conjunction. The rules about when to use a comma with as are the same as the rules for using commas with other subjordinating conjunctions, including while, when and because. Here they are:
If the clause with as comes first, a comma is generally required.
If the clause with as comes second, a comma is generally not required.
However, even in a sentence in which the "as clause" comes second, a comma may be necessary to clarify the meaning.