Would it be OK to ask a professor who recommended me to take a specific PhD program to write recommendation letter for another PhD program?
Yes. And any sane person would not hold this against you. It is also reality that people often have to apply to multiple places. (Also note that if you apply within Europe, you probably might upload the refeence letter yourself and can still decide to find another reference if the professor is insane.)
It could be different if the professor explicitly tells you not to apply to program B (but this does not seem to be the case from your question).