There are two ways to get this done. First, you can use DotNetNuke.Entities.Portals.PortalSettings.UpdateSiteSetting and DotNetNuke.Entities.Portals.PortalSettings.GetSiteSetting to set settings. This is actually just a shortcut to the module settings of the portal's Site Settings control. Because of this, you need to very careful and explicit in your naming to make sure that you don't accidentally overwrite a core setting or another module's settings.
You can also use DotNetNuke.Entities.Host.HostSettings.GetHostSetting and DotNetNuke.Entities.Host.HostSettingsController().UpdateHostSetting to write your own settings at the host level, making sure to include the PortalID in the setting when you do that. This has less chance of overwriting a core setting, but is otherwise basically the same deal as above.
Hope that helps,