The rules differ by country and are still changing, so treat ownership of purely AI-generated output as unsettled. Start with two documents: your employer's AI policy and the terms of the tool you use. Those usually say who may use the output and whether your inputs are stored or used for training.
In practice, reduce risk in four ways. Never paste confidential or client code into a consumer tool unless your company approves it. Review and meaningfully edit what the AI produces rather than shipping it untouched. Run a licence scanner on anything that looks copied from a library. Keep a note of which parts were AI-assisted. For a commercial product or a client contract, get a short legal opinion before you rely on any assumption.