のを, のに, のは, のが
In these cases, の is a nominalizer following a verb phrase, and the other part is a perfectly ordinary particle following a noun, which works the same way that it would following any other noun. By using の, we get something that can be followed by the particle, since a verb phrase generally cannot. (The rules for te-form are more complex.)
In particular, のに really is just の followed by に. Analyzing it as a single particle is something done to facilitate translation into English. For example, the sense of "even though" really comes from an idiomatic interpretation of how に attaches to the main verb, that makes sense when the thing you're attaching is a verb clause. (Keep in mind, in English you cannot say something like "even though the cat, ...". A subordinate clause is required, not simply a noun.) The の is a grammatical device that makes this attachment possible. (Grammatically, the whole construction works more like "despite my action", rather than "even though I acted".)
のこと
In this case, の is the ordinary particle の following some other noun, and こと is 事, the ordinary word for "thing". As one might expect, こと can function as a nominalizer in much the same way that の (in the previous sense) does. (See also [物]{もの}, [奴]{やつ} - though this kanji is rarely used - etc.)
You can tell which の it is according to what it follows. A nominalizer needs to follow something that clearly isn't a noun (it'll be easier to understand if you think of it as a synonym of 事, a noun that doesn't actually tell you anything about the object in question, such that the preceding part is the ordinary use of a verb clause, i-adjective etc. attributively). A particle needs to follow something that's sufficiently noun-like (which can in some cases include the te-form or masu-stem of a verb).