My first thought was fight fire with fire, which is very similar in underlying meaning: like the original saying, it is a description of directly countering one thing with more of the same thing. However, it is virtually always used in the context of a direct conflict, as suggested by the linked definition from Cambridge Dictionaries. I can imagine it being used if your ex is dating someone else in order to make you jealous and someone is advising you to reciprocate, or if your former employer is actively bad-mouthing you to prospective new employers and you are being advised to describe the ex-employer's bad behavior. But I don't think those situations are quite what you have in mind.
So, a couple that I think come closer:
To return to or resume an activity that one has previously failed at, had difficulty with, or which has previously caused one harm.
- I know you're discouraged after getting fired, but you need to get back on the horse that bucked you and start looking for work.
- I've been single for three years since my divorce, but now I think it's time to get back on the horse and start dating again.
(Farlex Dictionary of Idioms. In TheFreeDictionary.com)
This might be the closest in usage. As the dictionary's examples suggest, it is used in exactly the situations described. My only hesitation is that it doesn't exactly suggest that "getting back on the horse" by dating someone new or getting a new job will make you forget about the previous amour or position, but rather that if you don't "get back out there" right away that the situation will worsen in some way.
A remedy that contains a small amount of whatever caused the ailment:
- “When Anne had a bad hangover, Paul offered her a Bloody Mary and said, ‘Have a little of the hair of the dog that bit you.’”
(The American Heritage® New Dictionary of Cultural Literacy, Third Edition. In Dictionary.com.)
This is a little closer in underlying meaning: whatever the problem is, a little bit more of the same thing will cure it. However, as the example sentence above suggests, its overwhelming usage now is for drinking more alcohol to combat a hangover. It is still occasionally used in other situations, however, as for example:
[Trent's fiancée recently left him, and his cousin has just twisted his arm to "escort" a woman to a week-long wedding.] "Hey, I'm sorry that it has to be a wedding. But maybe it'll be good for you. You know, a hair-of-the-dog kind of thing," she added with a wobbly smile. Hair of the dog. Huh. If that were the case, he was about to choke down one supersized Bernese mountain dog kind of milkshake over the next few weeks. (Jennifer Shirk, Wedding Date for Hire, 2015)
Note: I got called away in the middle of composing this (darn those real-life jobs) and I see that Prodikl has beat me to the punch with hair of the dog and bjmc with fight fire with fire. I'm going to leave the answer as-is at least for now, and up-vote the other answers.