Yes, it is safe to take both as prescribed. A total of 4.4 mcg of
Vitamin B12 daily is within safe limits and may be needed if your B12 levels are low or if absorption is poor.
Your doctor likely prescribed both to ensure adequate intake. You can safely follow the advice, but if unsure, recheck your B12 levels after a few weeks.