In that case, you can try assigning the value of last_name to a variable and then use that variable to access the product:
{% assign product_handle = customer.last_name %}
{% assign product = all_products[product_handle] %}
{%- if product != nil -%}
{{ product.title }}
{%- else -%}
Product not found
{%- endif -%}