When and how did Claude take a part of Ciel's soul? In the anime of Kuroshitsuji (Black Butler) season 2, Sebastian was at some point not able to consume Ciel's soul, because Claude had a part of it.

When did Claude manage to get it and how?
I'm not positive exactly what part you're talking about because it's been a while since I watched that part of the show, and your question is a bit vague.

Here's what happens:

Sebastian doesn't want to consume Ciel's soul as it is (as of the start of Kuroshitsuji II) because he doesn't remember taking his revenge, so his soul is incomplete. As such, Sebastian and Claude make a bargain to allow Ciel to take a second revenge, this time on Alois. Both think that, after the second revenge will happen, they will be able to get Ciel and consume his soul.

Claude then kills Alois and puts his soul in a ring.

Following that, from this:


  It is shown that [Claude] is keeping a close eye on Sebastian and Ciel as they embark in another assignment from the Queen when Sebastian becomes occupied in a fight with William T. Spears, Ciel is arrested by the police who believe he's Alois Trancy and is identified by Hannah as Alois. Ciel is then tortured, which Claude and Hannah override. While Ciel is in a weak state after heavy and severe treatment Claude begins hypnotizing him and then places Alois's ring on Ciel's finger causing Alois's memories to mix in with Ciel's memories; this causes Ciel to believe that Sebastian was the cause for the death of his parents and his "brother," Luka Macken. When Sebastian finally reaches Ciel, Ciel pushes him away and refers to Claude as his butler. Claude then whispers to Ciel to order Sebastian to leave his sight, which Ciel does willfully. Claude then takes the weak and tired Ciel back to the Trancy mansion where he is warmly welcomed.