If you are dealing with a category page, you would simply use conditional tags, as suggested by @milo:
if ( is_category( 'cat-1' ) ) {
$url="my-background-image-url-1.ext";
} else if ( is_category( 'cat-2' ) ) {
$url="my-background-image-url-2.ext";
}
remember, you could pass in a category slug as well as a category name or an array containing any of these values.
if you are dealing with woocommerce categories, you could use the woocommerce category image as background image and then query the woocommerce category. if you want to use the woocommerce category image soewhere else, you could simply hardcode the image corresponding to the category slug like:
if ( is_product_category() ){
global $wp_query;
$cat = $wp_query->get_queried_object();
$my_slugs = array( 'category-slug-1', 'category-slug-2' );
if ( in_array( $cat->slug, $my_slugs ) {
$url="my-background-image-url-" . $cat->slug . '.ext';
}
}