There are many type of anti ship missile that can be launched from submarine such as Brahmos, Moskit, 3M54K Club, Sea dragon. Submarine are not affected by radar horizon like surface ship, while their still retain the range and speed like the version launched from surface ship. a Brahmos launched from submarine can still fly at Mach 3 and reach 300 km. Secondly, because of their low noise signature a submarine can't be detected from long range and because they are underwater where drag is high, all weapons that can be used against them such as torpedo, mine don't have long range either.
Even the ASROC which is essentially a torpedo on top of a rocket also have very short range and much lower speed than a submarine launched anti ship missile, commonly ASROC range is only 24 km at speed of about Mach 1
An aircraft carrier can carry anti submarine helicopter, but these things for sure doesn't fly as quick as submarine launched anti ship missiles and I don't think they can detect submarine from as far as submarine can detect an aircraft carrier.
To sum up, submarine can detect surface ship from much longer distance, anti ship missile can fly much further and much faster than anti submarine rocket and torpedo, mine.
So, does surface ships have any way to counter submarine + antiship missile threat?