You choose all targets for Magma Opus as you cast the spell. This includes up to four targets for the first effect and two target permanents for the second effect.

Artwork
Loading artwork…
Magma Opus
Secrets of Strixhaven Commander · #318 · EN
Nonfoil—Foil—
Card rules
Magma Opus deals 4 damage divided as you choose among any number of targets. Tap two target permanents. Create a 4/4 blue and red Elemental creature token. Draw two cards.

, Discard this card: Create a Treasure token.
Mythic · Illustrated by Liiga Smilshkalne
Format legality
Brawl Legal
Commander Legal
Competitive Brawl Legal
Duel Legal
Gladiator Legal
Historic Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Pioneer Legal
Timeless Legal
Vintage Legal
Alchemy Not Legal
Future Not Legal
Old School Not Legal
Pauper Not Legal
Pauper Commander Not Legal
Penny Not Legal
PreDH Not Legal
Premodern Not Legal
Standard Not Legal
Standard Brawl Not Legal
Tlr Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
If somehow all of Magma Opus's targets are illegal as it tries to resolve, none of its effects happen. You will not create an Elemental token or draw two cards.
You must choose two different target permanents for the second effect. You may choose permanents that are already tapped.
The same permanent can be chosen as a target for each of the two instances of "target." That is, you can have Magma Opus both deal damage to a creature or planeswalker and then tap it. (We're having a hard time imagining why you would, but you're the brilliant student.)
You also choose how the 4 damage will be divided among the first group of targets as you cast Magma Opus. You must have at least 1 damage dealt to each of those targets.