Before usage of any boolean operation, and before marking physical entities.
Boolean difference is covered here: Using the GMSH Python API to generate complex meshes | Jørgen S. Dokken
And other operations and references here: Using subdomains in diffusion equation - #6 by dokken