If you look in the documentation for sys.dm_tran_locks you find this description for resource_associated_entity_id:
ID of the entity in a database with which a resource is associated. This can be an object ID, Hobt ID, or an Allocation Unit ID, depending on the resource type
The id will be an object ID if the lock is on table level. For a lock on page or row level, it will be the allocation unit ID for the index (partition) in most cases, but it can also be in a LOB area.
If you want to know the full rules for how to translated, have a look at the code of my beta_lockinfo where I do this work. (Search for sys.allocation_units to find the part where I do this.)