First of all we should remember that it is forbidden to travel to the lands of the mushrikeen or lands where there is a great deal of corruption and promiscuity. The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “I disavow myself of every Muslim who settles among the mushrikeen.” They said: “O Messenger of Allaah, why?” He said: “They should not be able to see one another’s fires.” Narrated by al-Tirmidhi, 1604; classed as saheeh by al-Albaani in Saheeh al-Tirmidhi.
If a person needs to travel to such countries and cannot avoid doing so, or if that will serve the public interest of the Muslims, then it is permissible to travel, but he has to learn enough of the rulings of Islam that he needs in this country, and he should avoid places of fitnah (temptation, tribulation) that may affect his religious commitment, as much as he can, whether that has to do with physical temptations that are available in the kaafir land or it has to do with doubts and specious arguments that the enemies of Islam throw at him, overtly or otherwise, to shake the faith that is in people’s hearts. See question no. 6154. If this trip requires him to shave off his beard, such as if he needs to go to a place where wearing a beard is forbidden, or he will exposed to mistreatment because of his beard, and he cannot bear it, then Shaykh Ibn Jibreen tells us that:
If he has no alternative but to go to that country, or if his going there will strengthen the Muslims, then there is nothing wrong with him shaving off his beard. But if he is going there only for some worldly gain or the mistreatment to which he will be exposed is something that he can bear, then it is not permissible for him to shave it off.
It should also be noted that if trimming his beard a little will be sufficient to ward off harm from himself, then doing that will be less serious than shaving it off. And Allaah knows best.