Since you did not share the deadlock, we cannot tell what is going on.
I would think that a better way to serialise the operation is to use an application lock:
EXEC sp_getapplock 'CreatePartition', 'Exclusive'
This would replace the two SELECT statements. I encourage you to read more about sp_getapplock in Books Online.
If this does not resolve the problem, you may be clashing with user processes. You need to capture the deadlock information. The easiest to do that is to enable trace flag 1222 by making it a startup parameter. This will write deadlock traces to the SQL Server errorlog.
Since deadlocks are captured by the System Health session, they should in theory be available there. However, I found this to be very unreliable.