Monkey D. Luffy learns Haki during the two-year time skip in the One Piece series, specifically between episodes 516 and 517 in the anime and chapters 597-598 in the manga. During this time, Luffy trains on the island of Rusukaina under Silvers Rayleigh, also known as the Dark King, where he learns to use all three types of Haki: Observation Haki, Armament Haki, and Conqueror's Haki. Although Luffy possessed Conqueror's Haki innately (a rare ability), he trained to control and master it along with the other two Haki types during this period.
Before this formal training, Luffy had unknowingly used his Conqueror's Haki on a few occasions, such as during his fight against the Gorgon Sisters, in Impel Down, and at Marineford, but he did not fully understand or control it until after his training with Rayleigh.
Later in the series, especially by the Wano Country arc, Luffy further advances his mastery, including learning advanced Armament Haki techniques and improving his Conqueror's Haki to infuse it with greater power.