It's regulated by most countries having signed
https://en.wikipedia.org/wiki/Outer_Space_TreatySpecifically in this case it's covered by these four items:
* outer space shall be free for exploration and use by all States;
* States shall be responsible for national space activities whether carried out by governmental or non-governmental entities;
* States shall be liable for damage caused by their space objects; and
* States shall avoid harmful contamination of space and celestial bodies.
Thusly: the US is free to use space as it sees fit and thus allows US companies to use it as long as they follow US regulations. If the US or a US company damages property of another country then the US is liable for such damage (and can be billed for the damage/cleanup) and the US is responsible if SpaceX fills orbit with debris.
NASA and the US have also recently created the https://en.wikipedia.org/wiki/Artemis_Accords which are a interpretation of sorts of the outer space treaty and some nations have signed on to that interpretation, which has these bullet points:
> The Signatories commit to plan for the mitigation of orbital debris, including the safe, timely, and efficient passivation and disposal of spacecraft at the end of their missions, when appropriate, as part of their mission planning process. In the case of cooperative missions, such plans should explicitly include which Signatory has the primary responsibility for the end-of-mission planning and implementation.
> The Signatories commit to limit, to the extent practicable, the generation of new, long-lived harmful debris released through normal operations, break-up in operational or post-mission phases, and accidents and conjunctions, by taking appropriate measures such as the selection of safe flight profiles and operational configurations as well as post-mission disposal of space structures.