If there are many service classes, and each service class has many services, is the following sentence correct?
Selecting the locally optimal service from each service class does not create a globally optimal solution.
There is a single "locally optimal service" in each class, so this noun phrase should be singular, which it is.
Unless each immediately follows a plural noun phrase (which it does not here), then what follows should be singular, which service class is.
The gerund is used to turn the verb select into a noun, and the entire phrase above is a noun phrase for the process described, which is singular.
Three places number comes up, all of them singular, and all of them treated as singular. You're good!