I have no experience with overhead environment so will be writing about OW only. I also used to have a problem with this and the following helped me:
1) In case you dive often in area with lot of boat traffic, practise SMB deployment beforehand so you become confident in doing it. That will reduce a stress/danger from surfacing when you get lost.
2) Find couple of shallow dive sites you can dive from land, grab a buddy who is good in navigation and agree with him/her you are going to lead the dive. Breef them that you want their interference only if there is a risk of a dangerous situation. If you are just lost - let them you to resolve the situation.
3) Allow yourself to get lost. If you get lost, shoot SMB, surface, take a new compass course, pack SMB, go down, continue. Repeat if needed.
4) Realise that everybody gets lost sometimes. Yes, practising navigation skills will of course help a lot, but the magical solution is not to learn how to never get lost (because that will just never happen), but shift the mindset a bit - once you become confident in resolving situations when you got lost, you will realise it is not such a big deal to get lost and you will be no longer afraid of "it can happen".