Let me suggest a slightly different path for this one.
First, start with measuring the battery voltage while the tractor is running at half throttle, with the headlights off. Is it above 12.7 volts?
If above 12.7 volts and the light stays on, then the voltage sensor is bad ... a fairly common problem ... or a wiring problem to the voltage sensor. That's C30265, $22.79 and available for immediate shipment.
If below 12.7 volts, then either the battery (could be), rectifier (common failures), or something in the generator is wrong (uncommon).
All true comments about the ignition switch also, but I don't think this will be the cause of an Onan keeping the charge light on ...
Get parts at your local Ingersoll dealer, or if you care to, drop an eMail off my ID to get them mailorder.