Where do you have to set the topic or subject markers "wa" and "ga" in sentences with several clauses?
Somewhere before the predicate the subject corresponds to. To put it very simply, Japanese sentences with more than one clause would look something like this:
S1 (S2 (S3 P3) P2) P1
(typically found in complex sentences involving relative clauses)
S1 P1, S2 P2, S3 P3
(typically found in compound sentences)
S1 (S2 P2) P2, S3 P3
Where S means subject, P means predicate (verbs, adjectives, copulae (だ/です)). All objects and modifiers are omitted. This means that in Japanese sentences, a subject always comes before its corresponding predicate, but one sentence can be deeply nested.
Consider this sentence, which I feel is fairly simple and easy:
私はこれはピカソが描いた絵だと思います。
S1 (S2 (S3 P3) P2) P1
I think this is a picture Picasso painted.
Three nouns (subjects) marked with は or が appear in succession. From outer to inner, 私は—思います, これは—だ and ピカソが—描いた form three clauses.
But subjects can be omitted when they are not important:
これはピカソが描いた絵だと思います。
(S2 (S3 P3) P2) P1
I think this is a picture Picasso painted.
私はピカソが描いた絵だと思います。
S1 ((S3 P3) P2) P1
I think [it] is a picture Picasso painted.
ピカソが描いた絵だと思います。
((S3 P3) P2) P1
I think this is a picture Picasso painted.
As a result, you will very often see a sentence with three (or more) predicates and only one (or even no) explicit subject. And thanks to the particle system, you can change the word order to a certain degree. Still, a subject almost always comes before its predicate (there are exceptional 転置法 sentences, though).
これはピカソが描いた絵だと私は思います。
(S1 (S3 P3) P2) S1 P1
I think this is a picture Picasso painted.
Of course even more deeply nested sentences are possible:
私はこれはピカソが彼が髪が長い少年だった時代に描いた絵だと思います。
S1 (S2 (S3 (S4 (S5 P5) P4) P3) P2) P1
I think this is a picture Picasso painted when he was a boy with long hair.
From here, you have to practice. Parsing deeply nested sentences is one of the most difficult challenges in mastering both English and Japanese. Actually, ordinary Japanese students take years to get used to English relative clauses (and many people simply fail).