Obeying a command to do something not permitted in Islam
If a person is ordered to perform a certain assignment at his work, he should consider itif the act does not involve any disobedience to Allah (subhaanahu WA ta'aala) he should execute it. Otherwise, if it does involve some disobedience to Allah (subhaanahu WA ta'aala), he should not obey the command, or else he will be a partner in sin and wrong-doing. The Prophet (peace be upon him) said:
"A human must not be obeyed if that (i.e., obeying the human) causes disobedience to Allah (subhaanahu wa ta'aala). Indeed, obedience is only in righteous deeds"
(Sahih Al-Bukhari with Fath Al-Bari, 13/121; Ahmad, 1/91; and the context is found in Al-Silsilah As-Sahihah, No. 181)
And Allah (subhaanahu wa ta'aala) said (about the people who went astray) in the Qur'an (an interpretation of the meaning):
"They will say: Our Lord! We followed in the footsteps of our leaders and elders and they misguided us from the right path".