This part is not necessarily clear from your problem description but I am going to assume that you can only put one object per compartment.
If you drop the fact that putting together object x and y in the same bag can have an impact on the objective function, then you can model your problem as a min cost flow problem (which can be efficiently solved):
Each object is represented by a node.
Each compartment is represented by a node.
An arc of capacity 1 and cost 0 links the source of the graph to each object node.
An arc of capacity 1 and cost 0 links each compartment node to the sink of the graph.
An arc of capacity 1 and cost between 0 and -6 links every object node to every compartment node (-6 because we reverse the costs in order to have a minimization problem).
However, this is not your original problem description. In order to capture the cost of combining two objects in the same bag you could model your problem as a Mixed Integer Problem, and solve it with a dedicated solver (see glpk or cbc for open source ones, cplex or gurobi for commercial ones). If you decide to go this way, you could adopt the following model:
For each pair of object and compartment in a given bag define a binary variable indicating whether or not that object is put in that compartment of that bag. The contribution of this variable to the objective function is between 0 and 6.
For each object add a constraint stating that the sum of all the associated binary variable linking it to a given bag compartment should be less or equal than one.
For every pair of objects add a binary variable representing if the two objects are combined in the same bag. The contribution of this variable to the objective function should be between 0 and -3.
For every combination of objects pair and bag add a constraint stating that the binary variable representing if the two objects are combined in the same bag should be bigger or equal to -1 + the sum of all assignment variable linking one of those two objects with a compartment of the bag.
Regarding a heuristic approach to the problem, you could do the following thing:
Start with the first compartment of the first bag:
Assign the object that leads to the biggest increase of the score. Break ties by selecting the object for which the sum of its danger with remaining bags is minimum. Remove the object from the list of remaining objects, move on to the next compartment.