English is a second language for me so I still have lots of questions regarding that.

So here it is:

Prepositions are usually placed at the end of a question, but is it really obligatory all the time?

How about questions like:

Who did you talk to at lunch yesterday?

* in this case, preposition is not at the very end of the question


What are you working on right now?

* the same case, you do not ask: What are you working right now on?


Can I ask:

Who did you sleep with last night?


Who did you sleep last night with?

What is correct and why? I am a bit confused in this matter.

Thank you very much

Don't put the prepositions at the very end. These are correct:
AnonymousWho did you talk to at lunch yesterday?
AnonymousWhat are you working on right now?
AnonymousWho did you sleep with last night?
In theory, it is usually also possible to place the preposition at the very beginning, but this is rarely done these days and sounds very formal and stilted:
To whom did you talk yesterday?

Keep the preposition close to the verb.

I talked to him. Who did you talk to? If you add "at lunch" that's fine, but keep the "to" with "talk."

I slept with him. Who did you sleep with? If you add "last night" that's fine too, but keep "with" with "sleep."

I'm working on a huge project. What are you working on? Again, you can add "right now" but don't move the "on" away from the the "working."

(As CB says, you can say "To whom did you talk" or "On what are you working" but it will sound very old fashioned and stiff.