Paste the following line.

sudo nano /etc/apache2/sites-available/owncloud.conf

Paste the following lines in the file after SSLCertificateKeyFile line.

<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15768000; preload"
</IfModule>

Save and close the file. Then reload Apache.

Paste the following lines.

sudo systemctl reload apache2

a2enmod headers

Activate ssl site.

sudo a2enmod ssl
sudo a2ensite owncloud-ssl.conf
sudo service apache2 restart

Disable old site

sudo a2dissite 000-default.conf

sudo a2dissite default-ssl.conf