Self soothing?

When do babies learn how to self soothe?

Every time I try to put my baby down for bed before midnight he sleeps 30 mins and wakes up and won’t go back to bed even if I intervene with a pacifier or rocking him.

However, if he’s on his swing he’ll go right back to sleep. I’m frustrated because he won’t go to bed for the night until midnight any sleeping before that has to be done in a swing.

How can I change this?

FYI he’s 15 weeks old