One way is by looking on Google Search Console (if you don't have it set up yet for your domain, set it up). Look under "Security and manual actions" and then select "Manual actions". If it has a manual action against it, it will show up there.
I only had that happen to me once, after I bought an expired domain, I guess it had been used for spammy stuff before. Anyway if there is a manual action on your domain from Google, there is a way to appeal it, but you will need to explain why and show that you have made changes to your site. For example in my case, I showed evidence that the domain changed hands and that I had put up completely fresh content, so the old spammy stuff wasn't there anymore. They reviewed it and removed the manual action and all was well.
Of course, I'm sure there are other types of penalty where it's not as obvious or where there isn't a place to check like this, but at least check quickly to rule this one out by going on GSC.