Next-to-leading order QCD corrections to inclusive heavy-flavor production in polarized deep-inelastic scattering