You can prefix the rule
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
To your rule RewriteCond %{HTTPS} off
so that it stays
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This would generate three types of redirection
request: http://www.midominio.com
redirect-> https://www.midominio.com (regla2)
request: http://midominio.com
redirect-> https://www.midominio.com (regla1)
request: https://midominio.com
redirect-> https://www.midominio.com (regla1)
The fourth case is
request: https://www.midominio.com
And that is not subject to redirection.