Is it against code to have Romex sitting on top of gas pipes?
There is no line in the NEC that says NM cable may never touch a gas line. What the code does say is that the gas piping cannot be doing the work of your cable straps, and that is the violation an inspector will actually write. Cable draped across a gas line in a basement or attic is almost always a support problem, not a clearance problem.
The support rule is the one that bites
Section 300.11 of the 2023 NEC requires wiring to be securely fastened in place, and it is explicit that raceways and cables shall not be used as a means of support for other wiring or equipment except where specifically permitted. The companion idea applies here: your NM cable has to be supported by the building structure or by listed cable supports, not by whatever pipe happens to run in the same joist bay.
Section 334.30 gives the numbers for NM cable. It must be secured within 12 inches of every box, cabinet, or fitting, and at intervals not exceeding 4 1/2 feet, using staples, cable ties listed and identified for securement, straps, hangers, or similar fittings designed and installed so the cable is not damaged. A cable that sags onto a gas pipe between two distant staples fails that spacing requirement whether or not the pipe is there.
Physical damage and sharp edges
Section 300.4 covers protection against physical damage. Where NM cable crosses metal piping there can be an abrasion point, especially if the pipe carries vibration from a furnace or water heater. Section 334.15(B) requires NM cable in exposed work to closely follow the surface of the building finish or running boards, which is another reason the cable should be strapped to framing instead of resting on mechanical systems.
Bonding is a separate requirement
Section 250.104(B) requires metal piping systems, including gas piping, that are likely to become energized to be bonded to the service equipment enclosure, the grounded conductor at the service, the grounding electrode conductor, or the electrodes used. The bonding conductor is sized per Table 250.122 using the rating of the circuit that may energize the piping. That rule exists precisely because electrical wiring and gas piping share the same building cavities.
Corrugated stainless steel tubing deserves extra attention. CSST manufacturers publish bonding instructions that go beyond the base NEC language, and 250.104(B) points you to those instructions through 110.3(B). If the yellow CSST in the house was never bonded, that is a far more serious finding than a cable lying on a black iron pipe.
Field takeaway
Move the cable. Strap it to the joist or a running board so it is supported every 4 1/2 feet and within 12 inches of each box, keep it off the piping so nothing abrades, and confirm the gas piping system is bonded per 250.104(B). None of that takes long, and it clears the finding before the inspector has to write it.