All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
Having sexual intercourse with an animal is something prohibited and included in the saying of Allaah The Almighty: {And do not approach immoralities - what is apparent of them and what is concealed.}[Quran 6:151]
Regarding that act, the Prophet, sallallaahu ‘alayhi wa sallam, said: “Whoever has intercourse with an animal, kill him and kill the animal.” [Shu‘ayb Al-Arnaa'oot said: its chain of narrators is good]
As for its punishment, the most preponderant opinion, which is the opinion of the majority of scholars, is that there is no Hadd (i.e. the legal punishment prescribed by the Sharee‘ah [Islamic law]) for the one who had sexual intercourse with an animal; however, Ta'zeer (a discretionary punishment [whose measure is not fixed by the Sharee’ah] that the Muslim ruler imposes) should be carried out on him to deter him.
However, the one who did that should conceal his sin and not tell anyone about it. Also, he should turn with sincere repentance to Allaah The Almighty along with truthful regret and resolving never to do such an evil deed again for it goes against religion and sound nature.
Allaah Knows best.