If he was a friend, then as a friend I could talk to him and tell him to lay off. If he continued and it was really bothering me that bad I would stop hanging around him as much. If that still didn't work I would find a new friend.
If the person is a friend be straight with them. If they don't like what u have to say then to damn bad. If that doesn't work stay away from them for awhile.
I'm not sure about your laws... But over here, if someone is doing that to you in the workplace and a 3rd party hears it and finds it offensive and reports it... The person doing the jokes can be fired!!!! But if its a good friend i would just come out and ask, whats with all the sex jokes??? And then i would ask them to give it a rest!!!!