WooCommerce uses a single hook to display many things and just changing the hook priorities change the order of elements.
Just change the hook and their order to achieve your goal.
add_action( 'woocommerce_single_product_summary', 'my_add_product_cat', 6);
add_action( 'woocommerce_shop_loop_item_title', 'my_add_product_cat', 11);
I have given woocommerce_single_product_summary
priority to 6
because single product title displayed at same hook with priority of 5
.
The same thing I did for archive products title.