The correct place to store public key on the web is the certificate you request from a CA (Certificate Authority. Many are paid, but there are ones that are free). You generate your key-pair and creates a "Certificate Signing Request" and the CA issues a certificate to you once they've done some verification.
Also, the public key for encryption is nowadays not stored on the certificate. Rather, servers generates and signs a public key used for ephemeral key exchange.
If it's not a web application (e.g. SSH), then there's usually a trusted channel through which you transfer server public key to your local storage for future use.