Sometimes, mostly in summer, Safari will start to suspiciously jump from one website to another. For example, on Google, when I click on a link of Wikipedia, it jumps to a weird "tune up my Mac" site. Then after about a minute, it switched back. Is it a virus or a settings problem?
Sounds like you installed some software that came with a PUP that acts like adware. There are many of these that try to install unwanted programs during an install. They know that people just click OK while installing so they bundle them into the installer for another program.
Read here and check out what programs you have installed over the past few weeks or months. Uninstall third party add-ones until it goes away.
It's either a pop-up, which you get from an installed app, or adware, which you get from an installed app or a from your browser add-ons, or both.
I recommend you get an adware remover just for starters. I hate browser hijackers.