The Court of Arbitration for Sport said Ziga Jeglic tested positive for fenoterol in an in-competition test. Fenoterol is a drug designed to open the airways to the lungs.
"I take the mentioned drug due to asthma under medical advice," Jeglic said in a statement, adding he was tested on Friday. "It has been prescribed to me after testing for respiratory problems in Slovakia in 2017. Unfortunately I have forgot to declare it as (a therapeutic use) exception."
Jeglic was suspended from the games and has been ordered to leave the athletes village within 24 hours.
"I have overlooked the difference between comparable drugs, which are allowed and would enable me to use it for my respiratory problems during the Olympics," he said. "I apologize for my negligence to all the persons involved and I accept the further anti-doping procedures."
Slovenia played Norway in men's hockey on Tuesday and lost 2-1 in overtime, but Jeglic was scratched from the team ahead of the announcement about his positive test.
The 29-year-old forward played in all three preliminary-round games and had an assist. He also scored the winner in a shootout Saturday as Slovenia beat Slovakia 3-2.
This is the second consecutive international tournament from which Jeglic has been suspended. He was banned for two games at the world championships last year for swinging his skate at Switzerland winger Thomas Rufenacht.
In the Kontinental Hockey League, Jeglic plays for Neftekhimik Nizhnekamsk. He has two goals and four assists in 26 games this season.
Japanese short-track speedskater Kei Saito failed a pre-competition test in Pyeongchang and Russian curler Alexander Krushelnitsky, who won a bronze medal, tested positive during the games.