What are the rule for placing the do in the sharp keys?

In major 'sharp' keys, you find the key by counting up one line or space from the last sharp, e.g is the last sharp is D-sharp, the key is E major.

For minor keys it is a little bit different, if you have 3 or more sharps you count the THIRD TO LAST sharp in the key (e.g if you have 5 sharps, and F-sharp is the third-to-last sharp, the key is going to be G-sharp minor. For minor keys with less than three sharps, you subtract three sharps from the major key. B major has 5 sharps, whilst B minor has only two, so five minus three equals two.

I hope this answers your question.